pacman::p_load(sjPlot, htmltools, sjlabelled,readr, summarytools, haven, dplyr,kableExtra,readxl, ggplot2,ggtext)
# BBDD
ola1<-read_dta("../input/data/proc/data_01.dta")
ola2<-read_dta("../input/data/proc/data_02.dta")
ola3<-read_dta("../input/data/proc/data_03.dta")

#data_wide <- full_join(x = ola1, #datos ola 1
#y = ola2, #datos ola 2
#by = "folio_encuestado", #identificador
#aplica sufijo a variables que se repiten entre olas
#suffix = c("_w01",
#"_w02")) %>%
#left_join(ola3,
#by = "folio_encuestado")

# n fijado a ola 3
data_wide <- left_join(x = ola3, #datos ola 3
y = ola2, #datos ola 2
by = "folio_encuestado", #identificador
#aplica sufijo a variables que se repiten entre olas
suffix = c("_w03",
"_w02")) %>%
left_join(ola1,
by = "folio_encuestado")

Cruces con participación política

Diversificación de los repertorios de participación

Dependencia administrativa establecimiento

Participación política durante 3ro y 4to medio

# Listado de variables diversificación

#__Durante el periodo en que cursaba 3° y 4° Medio, ¿realizó algunas de las siguientes actividades (dentro o fuera del liceo)?__

#+ Participar en marchas o protestas pacíficas (part_pol_marcha_pas)

#+ Participar en marchas o protestas con disturbios (part_pol_marcha_dis)

#+ Participar en bloqueo de calles o carreteras (part_pol_bloqueo)

#+ Pintar o rayar paredes con demandas o consignas (part_pol_rayar)

#+ Participar en la toma de un edificio o institución (part_pol_toma)

#+ Trabajar como voluntario en servicios a la comunidad (part_pol_volunt)

#+ Firmar peticiones, presencialmente o por internet (part_pol_firma.y)

#+ Participar en una marcha con mis amigos (marcha_amig.y)

#+ Participar en una marcha con alguno de mis padres (marcha_pad.y)

#+ Participar en una marcha con otros miembros de mi familia (marcha_fam.y)

#__Durante el periodo en que cursaba 3° y 4° Medio, ¿con que frecuencia realizaba las siguientes actividades?__

#+ Usar internet para buscar información sobre temas sociales y/o políticos (part_pol_online)

#+ Postear imágenes o mensajes acerca de temas sociales y/o políticos en internet (part_online_post)

#+ Compartir o comentar en el posteo de otra persona acerca de temas sociales y políticos (part_online_com)

#+ Seguir a personas en redes sociales por su contenido sobre temas sociales y políticos (part_online_seg)
#sjPlot::view_df(data_wide, show.frq =TRUE,show.prc =TRUE,file="codebook.html") # funciona sin encoding conectado a
### Recodificar variables
#se excluye + Participar en una marcha con compañeros del colegio (s2_p_e_05_13)
data_wide$part_pol_marcha_pas_rec = ifelse(data_wide$part_pol_marcha_pas==1|data_wide$part_pol_marcha_pas==2,0,1)
data_wide$part_pol_marcha_dis_rec = ifelse(data_wide$part_pol_marcha_dis==1|data_wide$part_pol_marcha_dis==2,0,1)
data_wide$part_pol_bloqueo_rec = ifelse(data_wide$part_pol_bloqueo==1|data_wide$part_pol_bloqueo==2,0,1)
data_wide$part_pol_rayar.y_rec = ifelse(data_wide$part_pol_rayar.y==1|data_wide$part_pol_rayar.y==2,0,1)
data_wide$part_pol_toma.y_rec = ifelse(data_wide$part_pol_toma.y==1|data_wide$part_pol_toma.y==2,0,1)
data_wide$part_pol_volunt_rec = ifelse(data_wide$part_pol_volunt==1|data_wide$part_pol_volunt==2,0,1)
data_wide$part_pol_firma.y_rec = ifelse(data_wide$part_pol_firma.y==1|data_wide$part_pol_firma.y==2,0,1)
data_wide$marcha_amig.y_rec = ifelse(data_wide$marcha_amig.y==1|data_wide$marcha_amig.y==2,0,1)
data_wide$marcha_pad.y_rec = ifelse(data_wide$marcha_pad.y==1|data_wide$marcha_pad.y==2,0,1)
data_wide$marcha_fam.y_rec = ifelse(data_wide$marcha_fam.y==1|data_wide$marcha_fam.y==2,0,1)
data_wide$part_pol_online_rec = ifelse(data_wide$part_pol_online==1|data_wide$part_pol_online==2,0,1)
data_wide$part_online_post_rec = ifelse(data_wide$part_online_post==1|data_wide$part_online_post==2,0,1)
data_wide$part_online_com_rec = ifelse(data_wide$part_online_com==1|data_wide$part_online_com==2,0,1)
data_wide$part_online_seg_rec = ifelse(data_wide$part_online_seg==1|data_wide$part_online_seg==2,0,1)
### Crear variable
data_wide$part_pol_3y4 = as.numeric(data_wide$part_pol_marcha_pas_rec + data_wide$part_pol_marcha_dis_rec + data_wide$part_pol_bloqueo_rec + data_wide$part_pol_rayar.y_rec + data_wide$part_pol_toma.y_rec + data_wide$part_pol_volunt_rec + data_wide$part_pol_firma.y_rec + data_wide$marcha_amig.y_rec + data_wide$marcha_pad.y_rec + data_wide$marcha_fam.y_rec + data_wide$part_pol_online_rec + data_wide$part_online_post_rec + data_wide$part_online_com_rec + data_wide$part_online_seg_rec)
#table(data_wide$part_pol_3y4)
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_pol_3y4, na.rm=T),
               psych::describe(data_sub$part_pol_3y4, na.rm=T),psych::describe(data_priv$part_pol_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_pol_3y4,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_pol_3y4,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_pol_3y4,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_pol_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
tipo de dependencia administrativa de la escuela") + ylim(0,14)
#part_pol_3y4_colegio
ggsave(part_pol_3y4_colegio, file = "../output/graphs/part_pol_3y4_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Recodificar variables
data_wide$part_pol_firma_21_rec = ifelse(data_wide$part_pol_firma_21==1|data_wide$part_pol_firma_21==2,0,1)
data_wide$part_pol_marc_pac_21_rec = ifelse(data_wide$part_pol_marc_pac_21==1|data_wide$part_pol_marc_pac_21==2,0,1)
data_wide$part_pol_marc_dis_21_rec = ifelse(data_wide$part_pol_marc_dis_21==1|data_wide$part_pol_marc_dis_21==2,0,1)
data_wide$part_pol_bloq_21_rec = ifelse(data_wide$part_pol_bloq_21==1|data_wide$part_pol_bloq_21==2,0,1)
data_wide$part_pol_rayar_21_rec = ifelse(data_wide$part_pol_rayar_21==1|data_wide$part_pol_rayar_21==2,0,1)
data_wide$part_pol_toma_21_rec = ifelse(data_wide$part_pol_toma_21==1|data_wide$part_pol_toma_21==2,0,1)
data_wide$part_pol_com_21_rec = ifelse(data_wide$part_pol_com_21==1|data_wide$part_pol_com_21==2,0,1)
data_wide$marcha_amig_21_rec = ifelse(data_wide$marcha_amig_21==1|data_wide$marcha_amig_21==2,0,1)
data_wide$marcha_pad_21_rec = ifelse(data_wide$marcha_pad_21==1|data_wide$marcha_pad_21==2,0,1)
data_wide$marcha_fam_21_rec = ifelse(data_wide$marcha_fam_21==1|data_wide$marcha_fam_21==2,0,1)
data_wide$part_pol_online_info_21_rec = ifelse(data_wide$part_pol_online_info_21==1|data_wide$part_pol_online_info_21==2,0,1)
data_wide$part_pol_online_post_21_rec = ifelse(data_wide$part_pol_online_post_21==1|data_wide$part_pol_online_post_21==2,0,1)
data_wide$part_pol_online_com_21_rec = ifelse(data_wide$part_pol_online_com_21==1|data_wide$part_pol_online_com_21==2,0,1)
data_wide$part_pol_online_seg_21_rec = ifelse(data_wide$part_pol_online_seg_21==1|data_wide$part_pol_online_seg_21==2,0,1)
### Crear variable
data_wide$part_pol_es = as.numeric(data_wide$part_pol_firma_21_rec + data_wide$part_pol_marc_pac_21_rec + data_wide$part_pol_marc_dis_21_rec + data_wide$part_pol_bloq_21_rec + data_wide$part_pol_rayar_21_rec + data_wide$part_pol_toma_21_rec + data_wide$part_pol_com_21_rec + data_wide$marcha_amig_21_rec + data_wide$marcha_pad_21_rec + data_wide$marcha_fam_21_rec + data_wide$part_pol_online_info_21_rec + data_wide$part_pol_online_post_21_rec + data_wide$part_pol_online_com_21_rec + data_wide$part_pol_online_seg_21_rec)
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_pol_es, na.rm=T),
               psych::describe(data_sub$part_pol_es, na.rm=T),psych::describe(data_priv$part_pol_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_pol_es,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_pol_es,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_pol_es,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_pol_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
tipo de dependencia administrativa de la escuela") + ylim(0,14)
#part_pol_es_colegio
ggsave(part_pol_es_colegio, file = "../output/graphs/part_pol_es_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Recodificar variables
data_wide$part_pol_firma_20_rec = ifelse(data_wide$part_pol_firma_20==1|data_wide$part_pol_firma_20==2,0,1)
data_wide$part_pol_marc_pac_20_rec = ifelse(data_wide$part_pol_marc_pac_20==1|data_wide$part_pol_marc_pac_20==2,0,1)
data_wide$part_pol_marc_dis_20_rec = ifelse(data_wide$part_pol_marc_dis_20==1|data_wide$part_pol_marc_dis_20==2,0,1)
data_wide$part_pol_bloq_20_rec = ifelse(data_wide$part_pol_bloq_20==1|data_wide$part_pol_bloq_20==2,0,1)
data_wide$part_pol_rayar_20_rec = ifelse(data_wide$part_pol_rayar_20==1|data_wide$part_pol_rayar_20==2,0,1)
data_wide$part_pol_toma_20_rec = ifelse(data_wide$part_pol_toma_20==1|data_wide$part_pol_toma_20==2,0,1)
data_wide$part_pol_com_20_rec = ifelse(data_wide$part_pol_com_20==1|data_wide$part_pol_com_20==2,0,1)
data_wide$marcha_amig_20_rec = ifelse(data_wide$marcha_amig_20==1|data_wide$marcha_amig_20==2,0,1)
data_wide$marcha_pad_20_rec = ifelse(data_wide$marcha_pad_20==1|data_wide$marcha_pad_20==2,0,1)
data_wide$marcha_fam_20_rec = ifelse(data_wide$marcha_fam_20==1|data_wide$marcha_fam_20==2,0,1)
data_wide$part_pol_online_info_20_rec = ifelse(data_wide$part_pol_online_info_20==1|data_wide$part_pol_online_info_20==2,0,1)
data_wide$part_pol_online_post_20_rec = ifelse(data_wide$part_pol_online_post_20==1|data_wide$part_pol_online_post_20==2,0,1)
data_wide$part_pol_online_com_20_rec = ifelse(data_wide$part_pol_online_com_20==1|data_wide$part_pol_online_com_20==2,0,1)
data_wide$part_pol_online_seg_20_rec = ifelse(data_wide$part_pol_online_seg_20==1|data_wide$part_pol_online_seg_20==2,0,1)
### Crear variable
data_wide$part_pol_20 = as.numeric(data_wide$part_pol_firma_20_rec + data_wide$part_pol_marc_pac_20_rec + data_wide$part_pol_marc_dis_20_rec + data_wide$part_pol_bloq_20_rec + data_wide$part_pol_rayar_20_rec + data_wide$part_pol_toma_20_rec + data_wide$part_pol_com_20_rec + data_wide$marcha_amig_20_rec + data_wide$marcha_pad_20_rec + data_wide$marcha_fam_20_rec + data_wide$part_pol_online_info_20_rec + data_wide$part_pol_online_post_20_rec + data_wide$part_pol_online_com_20_rec + data_wide$part_pol_online_seg_20_rec)
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_pol_20, na.rm=T),
               psych::describe(data_sub$part_pol_20, na.rm=T),psych::describe(data_priv$part_pol_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_pol_20,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_pol_20,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_pol_20,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_pol_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
tipo de dependencia administrativa de la escuela") + ylim(0,14)
#part_pol_20_colegio
ggsave(part_pol_20_colegio, file = "../output/graphs/part_pol_20_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_pol_21_1s = as.numeric(data_wide$part_pol_firma.x_rec + data_wide$part_pol_marc_pac_rec + data_wide$part_pol_marc_dis_rec + data_wide$part_pol_bloq_rec + data_wide$part_pol_rayar.x_rec + data_wide$part_pol_toma.x_rec + data_wide$part_pol_com_rec + data_wide$marcha_amig.x_rec + data_wide$marcha_pad.x_rec + data_wide$marcha_fam.x_rec + data_wide$part_pol_online_info_rec + data_wide$part_pol_online_post_rec + data_wide$part_pol_online_com_rec + data_wide$part_pol_online_seg_rec)
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_pol_21_1s, na.rm=T),
               psych::describe(data_sub$part_pol_21_1s, na.rm=T),psych::describe(data_priv$part_pol_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_pol_21_1s,y=data_mun$weight_w02,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_pol_21_1s,y=data_sub$weight_w02,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_pol_21_1s,y=data_priv$weight_w02,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_pol_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
tipo de dependencia administrativa de la escuela") + ylim(0,14)
#part_pol_21_1s_colegio
ggsave(part_pol_21_1s_colegio, file = "../output/graphs/part_pol_21_1s_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_pol_21_2s = as.numeric(data_wide$part_pol_firma_21b_rec + data_wide$part_pol_marc_pac_21b_rec + data_wide$part_pol_marc_dis_21b_rec + data_wide$part_pol_bloq_21b_rec + data_wide$part_pol_rayar_21b_rec + data_wide$part_pol_toma_21b_rec + data_wide$part_pol_com_21b_rec + data_wide$marcha_amig_21b_rec + data_wide$marcha_pad_21b_rec + data_wide$marcha_fam_21b_rec + data_wide$part_pol_online_info_21b_rec + data_wide$part_pol_online_post_21b_rec + data_wide$part_pol_online_com_21b_rec + data_wide$part_pol_online_seg_21b_rec)
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_pol_21_2s, na.rm=T),
               psych::describe(data_sub$part_pol_21_2s, na.rm=T),psych::describe(data_priv$part_pol_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_pol_21_2s,y=data_mun$weight_w03,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_pol_21_2s,y=data_sub$weight_w03,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_pol_21_2s,y=data_priv$weight_w03,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_pol_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
tipo de dependencia administrativa de la escuela") + ylim(0,14)
#part_pol_21_2s_colegio
ggsave(part_pol_21_2s_colegio, file = "../output/graphs/part_pol_21_2s_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

Participación política durante 3ro y 4to medio

### Recodificar variables
#se excluye + Participar en una marcha con compañeros del colegio (s2_p_e_05_13)
data_wide$part_pol_marcha_pas_rec = ifelse(data_wide$part_pol_marcha_pas==1|data_wide$part_pol_marcha_pas==2,0,1)
data_wide$part_pol_marcha_dis_rec = ifelse(data_wide$part_pol_marcha_dis==1|data_wide$part_pol_marcha_dis==2,0,1)
data_wide$part_pol_bloqueo_rec = ifelse(data_wide$part_pol_bloqueo==1|data_wide$part_pol_bloqueo==2,0,1)
data_wide$part_pol_rayar.y_rec = ifelse(data_wide$part_pol_rayar.y==1|data_wide$part_pol_rayar.y==2,0,1)
data_wide$part_pol_toma.y_rec = ifelse(data_wide$part_pol_toma.y==1|data_wide$part_pol_toma.y==2,0,1)
data_wide$part_pol_volunt_rec = ifelse(data_wide$part_pol_volunt==1|data_wide$part_pol_volunt==2,0,1)
data_wide$part_pol_firma.y_rec = ifelse(data_wide$part_pol_firma.y==1|data_wide$part_pol_firma.y==2,0,1)
data_wide$marcha_amig.y_rec = ifelse(data_wide$marcha_amig.y==1|data_wide$marcha_amig.y==2,0,1)
data_wide$marcha_pad.y_rec = ifelse(data_wide$marcha_pad.y==1|data_wide$marcha_pad.y==2,0,1)
data_wide$marcha_fam.y_rec = ifelse(data_wide$marcha_fam.y==1|data_wide$marcha_fam.y==2,0,1)
data_wide$part_pol_online_rec = ifelse(data_wide$part_pol_online==1|data_wide$part_pol_online==2,0,1)
data_wide$part_online_post_rec = ifelse(data_wide$part_online_post==1|data_wide$part_online_post==2,0,1)
data_wide$part_online_com_rec = ifelse(data_wide$part_online_com==1|data_wide$part_online_com==2,0,1)
data_wide$part_online_seg_rec = ifelse(data_wide$part_online_seg==1|data_wide$part_online_seg==2,0,1)
### Crear variable
data_wide$part_pol_3y4 = as.numeric(data_wide$part_pol_marcha_pas_rec + data_wide$part_pol_marcha_dis_rec + data_wide$part_pol_bloqueo_rec + data_wide$part_pol_rayar.y_rec + data_wide$part_pol_toma.y_rec + data_wide$part_pol_volunt_rec + data_wide$part_pol_firma.y_rec + data_wide$marcha_amig.y_rec + data_wide$marcha_pad.y_rec + data_wide$marcha_fam.y_rec + data_wide$part_pol_online_rec + data_wide$part_online_post_rec + data_wide$part_online_com_rec + data_wide$part_online_seg_rec)
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_3y4, na.rm=T),
               psych::describe(data_ed_med$part_pol_3y4, na.rm=T),
               psych::describe(data_ed_ter$part_pol_3y4, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_3y4,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_3y4,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_3y4,y=data_ed_tec$weight_w01,na.rm=TRUE)
#pond3 <- stats::weighted.mean(x=data_ed_tec$part_pol_3y4,y=data_ed_tec$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_3y4,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
nivel educativo de la madre") + ylim(0,14)
#part_pol_3y4_colegio
ggsave(part_pol_3y4_colegio, file = "../output/graphs/part_pol_3y4_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Recodificar variables
data_wide$part_pol_firma_21_rec = ifelse(data_wide$part_pol_firma_21==1|data_wide$part_pol_firma_21==2,0,1)
data_wide$part_pol_marc_pac_21_rec = ifelse(data_wide$part_pol_marc_pac_21==1|data_wide$part_pol_marc_pac_21==2,0,1)
data_wide$part_pol_marc_dis_21_rec = ifelse(data_wide$part_pol_marc_dis_21==1|data_wide$part_pol_marc_dis_21==2,0,1)
data_wide$part_pol_bloq_21_rec = ifelse(data_wide$part_pol_bloq_21==1|data_wide$part_pol_bloq_21==2,0,1)
data_wide$part_pol_rayar_21_rec = ifelse(data_wide$part_pol_rayar_21==1|data_wide$part_pol_rayar_21==2,0,1)
data_wide$part_pol_toma_21_rec = ifelse(data_wide$part_pol_toma_21==1|data_wide$part_pol_toma_21==2,0,1)
data_wide$part_pol_com_21_rec = ifelse(data_wide$part_pol_com_21==1|data_wide$part_pol_com_21==2,0,1)
data_wide$marcha_amig_21_rec = ifelse(data_wide$marcha_amig_21==1|data_wide$marcha_amig_21==2,0,1)
data_wide$marcha_pad_21_rec = ifelse(data_wide$marcha_pad_21==1|data_wide$marcha_pad_21==2,0,1)
data_wide$marcha_fam_21_rec = ifelse(data_wide$marcha_fam_21==1|data_wide$marcha_fam_21==2,0,1)
data_wide$part_pol_online_info_21_rec = ifelse(data_wide$part_pol_online_info_21==1|data_wide$part_pol_online_info_21==2,0,1)
data_wide$part_pol_online_post_21_rec = ifelse(data_wide$part_pol_online_post_21==1|data_wide$part_pol_online_post_21==2,0,1)
data_wide$part_pol_online_com_21_rec = ifelse(data_wide$part_pol_online_com_21==1|data_wide$part_pol_online_com_21==2,0,1)
data_wide$part_pol_online_seg_21_rec = ifelse(data_wide$part_pol_online_seg_21==1|data_wide$part_pol_online_seg_21==2,0,1)
### Crear variable
data_wide$part_pol_es = as.numeric(data_wide$part_pol_firma_21_rec + data_wide$part_pol_marc_pac_21_rec + data_wide$part_pol_marc_dis_21_rec + data_wide$part_pol_bloq_21_rec + data_wide$part_pol_rayar_21_rec + data_wide$part_pol_toma_21_rec + data_wide$part_pol_com_21_rec + data_wide$marcha_amig_21_rec + data_wide$marcha_pad_21_rec + data_wide$marcha_fam_21_rec + data_wide$part_pol_online_info_21_rec + data_wide$part_pol_online_post_21_rec + data_wide$part_pol_online_com_21_rec + data_wide$part_pol_online_seg_21_rec)
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_es, na.rm=T),
               psych::describe(data_ed_med$part_pol_es, na.rm=T),
               psych::describe(data_ed_ter$part_pol_es, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_es,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_es,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_es,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond3 <- stats::weighted.mean(x=data_ed_tec$part_pol_es,y=data_ed_tec$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_es,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
nivel educativo de la madre") + ylim(0,14)
#part_pol_es_colegio
ggsave(part_pol_es_colegio, file = "../output/graphs/part_pol_es_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Recodificar variables
data_wide$part_pol_firma_20_rec = ifelse(data_wide$part_pol_firma_20==1|data_wide$part_pol_firma_20==2,0,1)
data_wide$part_pol_marc_pac_20_rec = ifelse(data_wide$part_pol_marc_pac_20==1|data_wide$part_pol_marc_pac_20==2,0,1)
data_wide$part_pol_marc_dis_20_rec = ifelse(data_wide$part_pol_marc_dis_20==1|data_wide$part_pol_marc_dis_20==2,0,1)
data_wide$part_pol_bloq_20_rec = ifelse(data_wide$part_pol_bloq_20==1|data_wide$part_pol_bloq_20==2,0,1)
data_wide$part_pol_rayar_20_rec = ifelse(data_wide$part_pol_rayar_20==1|data_wide$part_pol_rayar_20==2,0,1)
data_wide$part_pol_toma_20_rec = ifelse(data_wide$part_pol_toma_20==1|data_wide$part_pol_toma_20==2,0,1)
data_wide$part_pol_com_20_rec = ifelse(data_wide$part_pol_com_20==1|data_wide$part_pol_com_20==2,0,1)
data_wide$marcha_amig_20_rec = ifelse(data_wide$marcha_amig_20==1|data_wide$marcha_amig_20==2,0,1)
data_wide$marcha_pad_20_rec = ifelse(data_wide$marcha_pad_20==1|data_wide$marcha_pad_20==2,0,1)
data_wide$marcha_fam_20_rec = ifelse(data_wide$marcha_fam_20==1|data_wide$marcha_fam_20==2,0,1)
data_wide$part_pol_online_info_20_rec = ifelse(data_wide$part_pol_online_info_20==1|data_wide$part_pol_online_info_20==2,0,1)
data_wide$part_pol_online_post_20_rec = ifelse(data_wide$part_pol_online_post_20==1|data_wide$part_pol_online_post_20==2,0,1)
data_wide$part_pol_online_com_20_rec = ifelse(data_wide$part_pol_online_com_20==1|data_wide$part_pol_online_com_20==2,0,1)
data_wide$part_pol_online_seg_20_rec = ifelse(data_wide$part_pol_online_seg_20==1|data_wide$part_pol_online_seg_20==2,0,1)
### Crear variable
data_wide$part_pol_20 = as.numeric(data_wide$part_pol_firma_20_rec + data_wide$part_pol_marc_pac_20_rec + data_wide$part_pol_marc_dis_20_rec + data_wide$part_pol_bloq_20_rec + data_wide$part_pol_rayar_20_rec + data_wide$part_pol_toma_20_rec + data_wide$part_pol_com_20_rec + data_wide$marcha_amig_20_rec + data_wide$marcha_pad_20_rec + data_wide$marcha_fam_20_rec + data_wide$part_pol_online_info_20_rec + data_wide$part_pol_online_post_20_rec + data_wide$part_pol_online_com_20_rec + data_wide$part_pol_online_seg_20_rec)
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_20, na.rm=T),
               psych::describe(data_ed_med$part_pol_20, na.rm=T),
               psych::describe(data_ed_ter$part_pol_20, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_20,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_20,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_20,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond3 <- stats::weighted.mean(x=data_ed_tec$part_pol_20,y=data_ed_tec$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_20,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
nivel educativo de la madre") + ylim(0,14)
#part_pol_20_colegio
ggsave(part_pol_20_colegio, file = "../output/graphs/part_pol_20_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_pol_21_1s = as.numeric(data_wide$part_pol_firma.x_rec + data_wide$part_pol_marc_pac_rec + data_wide$part_pol_marc_dis_rec + data_wide$part_pol_bloq_rec + data_wide$part_pol_rayar.x_rec + data_wide$part_pol_toma.x_rec + data_wide$part_pol_com_rec + data_wide$marcha_amig.x_rec + data_wide$marcha_pad.x_rec + data_wide$marcha_fam.x_rec + data_wide$part_pol_online_info_rec + data_wide$part_pol_online_post_rec + data_wide$part_pol_online_com_rec + data_wide$part_pol_online_seg_rec)
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_21_1s, na.rm=T),
               psych::describe(data_ed_med$part_pol_21_1s, na.rm=T),
               psych::describe(data_ed_ter$part_pol_21_1s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_21_1s,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_21_1s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_21_1s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_21_1s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
nivel educativo de la madre") + ylim(0,14)
#part_pol_21_1s_colegio
ggsave(part_pol_21_1s_colegio, file = "../output/graphs/part_pol_21_1s_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_pol_21_2s = as.numeric(data_wide$part_pol_firma_21b_rec + data_wide$part_pol_marc_pac_21b_rec + data_wide$part_pol_marc_dis_21b_rec + data_wide$part_pol_bloq_21b_rec + data_wide$part_pol_rayar_21b_rec + data_wide$part_pol_toma_21b_rec + data_wide$part_pol_com_21b_rec + data_wide$marcha_amig_21b_rec + data_wide$marcha_pad_21b_rec + data_wide$marcha_fam_21b_rec + data_wide$part_pol_online_info_21b_rec + data_wide$part_pol_online_post_21b_rec + data_wide$part_pol_online_com_21b_rec + data_wide$part_pol_online_seg_21b_rec)
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_21_2s, na.rm=T),
               psych::describe(data_ed_med$part_pol_21_2s, na.rm=T),
               psych::describe(data_ed_ter$part_pol_21_2s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_21_2s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_21_2s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_21_2s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_21_2s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
nivel educativo de la madre") + ylim(0,14)
#part_pol_21_2s_colegio
ggsave(part_pol_21_2s_colegio, file = "../output/graphs/part_pol_21_2s_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

Participación política durante 3ro y 4to medio

### Recodificar variables
#se excluye + Participar en una marcha con compañeros del colegio (s2_p_e_05_13)
data_wide$part_pol_marcha_pas_rec = ifelse(data_wide$part_pol_marcha_pas==1|data_wide$part_pol_marcha_pas==2,0,1)
data_wide$part_pol_marcha_dis_rec = ifelse(data_wide$part_pol_marcha_dis==1|data_wide$part_pol_marcha_dis==2,0,1)
data_wide$part_pol_bloqueo_rec = ifelse(data_wide$part_pol_bloqueo==1|data_wide$part_pol_bloqueo==2,0,1)
data_wide$part_pol_rayar.y_rec = ifelse(data_wide$part_pol_rayar.y==1|data_wide$part_pol_rayar.y==2,0,1)
data_wide$part_pol_toma.y_rec = ifelse(data_wide$part_pol_toma.y==1|data_wide$part_pol_toma.y==2,0,1)
data_wide$part_pol_volunt_rec = ifelse(data_wide$part_pol_volunt==1|data_wide$part_pol_volunt==2,0,1)
data_wide$part_pol_firma.y_rec = ifelse(data_wide$part_pol_firma.y==1|data_wide$part_pol_firma.y==2,0,1)
data_wide$marcha_amig.y_rec = ifelse(data_wide$marcha_amig.y==1|data_wide$marcha_amig.y==2,0,1)
data_wide$marcha_pad.y_rec = ifelse(data_wide$marcha_pad.y==1|data_wide$marcha_pad.y==2,0,1)
data_wide$marcha_fam.y_rec = ifelse(data_wide$marcha_fam.y==1|data_wide$marcha_fam.y==2,0,1)
data_wide$part_pol_online_rec = ifelse(data_wide$part_pol_online==1|data_wide$part_pol_online==2,0,1)
data_wide$part_online_post_rec = ifelse(data_wide$part_online_post==1|data_wide$part_online_post==2,0,1)
data_wide$part_online_com_rec = ifelse(data_wide$part_online_com==1|data_wide$part_online_com==2,0,1)
data_wide$part_online_seg_rec = ifelse(data_wide$part_online_seg==1|data_wide$part_online_seg==2,0,1)
### Crear variable
data_wide$part_pol_3y4 = as.numeric(data_wide$part_pol_marcha_pas_rec + data_wide$part_pol_marcha_dis_rec + data_wide$part_pol_bloqueo_rec + data_wide$part_pol_rayar.y_rec + data_wide$part_pol_toma.y_rec + data_wide$part_pol_volunt_rec + data_wide$part_pol_firma.y_rec + data_wide$marcha_amig.y_rec + data_wide$marcha_pad.y_rec + data_wide$marcha_fam.y_rec + data_wide$part_pol_online_rec + data_wide$part_online_post_rec + data_wide$part_online_com_rec + data_wide$part_online_seg_rec)
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_3y4, na.rm=T),
               psych::describe(data_ed_med$part_pol_3y4, na.rm=T),
               psych::describe(data_ed_ter$part_pol_3y4, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_3y4,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_3y4,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_3y4,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_3y4,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
nivel educativo de la padre") + ylim(0,14)
#part_pol_3y4_colegio
ggsave(part_pol_3y4_colegio, file = "../output/graphs/part_pol_3y4_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Recodificar variables
data_wide$part_pol_firma_21_rec = ifelse(data_wide$part_pol_firma_21==1|data_wide$part_pol_firma_21==2,0,1)
data_wide$part_pol_marc_pac_21_rec = ifelse(data_wide$part_pol_marc_pac_21==1|data_wide$part_pol_marc_pac_21==2,0,1)
data_wide$part_pol_marc_dis_21_rec = ifelse(data_wide$part_pol_marc_dis_21==1|data_wide$part_pol_marc_dis_21==2,0,1)
data_wide$part_pol_bloq_21_rec = ifelse(data_wide$part_pol_bloq_21==1|data_wide$part_pol_bloq_21==2,0,1)
data_wide$part_pol_rayar_21_rec = ifelse(data_wide$part_pol_rayar_21==1|data_wide$part_pol_rayar_21==2,0,1)
data_wide$part_pol_toma_21_rec = ifelse(data_wide$part_pol_toma_21==1|data_wide$part_pol_toma_21==2,0,1)
data_wide$part_pol_com_21_rec = ifelse(data_wide$part_pol_com_21==1|data_wide$part_pol_com_21==2,0,1)
data_wide$marcha_amig_21_rec = ifelse(data_wide$marcha_amig_21==1|data_wide$marcha_amig_21==2,0,1)
data_wide$marcha_pad_21_rec = ifelse(data_wide$marcha_pad_21==1|data_wide$marcha_pad_21==2,0,1)
data_wide$marcha_fam_21_rec = ifelse(data_wide$marcha_fam_21==1|data_wide$marcha_fam_21==2,0,1)
data_wide$part_pol_online_info_21_rec = ifelse(data_wide$part_pol_online_info_21==1|data_wide$part_pol_online_info_21==2,0,1)
data_wide$part_pol_online_post_21_rec = ifelse(data_wide$part_pol_online_post_21==1|data_wide$part_pol_online_post_21==2,0,1)
data_wide$part_pol_online_com_21_rec = ifelse(data_wide$part_pol_online_com_21==1|data_wide$part_pol_online_com_21==2,0,1)
data_wide$part_pol_online_seg_21_rec = ifelse(data_wide$part_pol_online_seg_21==1|data_wide$part_pol_online_seg_21==2,0,1)
### Crear variable
data_wide$part_pol_es = as.numeric(data_wide$part_pol_firma_21_rec + data_wide$part_pol_marc_pac_21_rec + data_wide$part_pol_marc_dis_21_rec + data_wide$part_pol_bloq_21_rec + data_wide$part_pol_rayar_21_rec + data_wide$part_pol_toma_21_rec + data_wide$part_pol_com_21_rec + data_wide$marcha_amig_21_rec + data_wide$marcha_pad_21_rec + data_wide$marcha_fam_21_rec + data_wide$part_pol_online_info_21_rec + data_wide$part_pol_online_post_21_rec + data_wide$part_pol_online_com_21_rec + data_wide$part_pol_online_seg_21_rec)
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_es, na.rm=T),
               psych::describe(data_ed_med$part_pol_es, na.rm=T),
               psych::describe(data_ed_ter$part_pol_es, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_es,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_es,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_es,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_es,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
nivel educativo de la padre") + ylim(0,14)
#part_pol_es_colegio
ggsave(part_pol_es_colegio, file = "../output/graphs/part_pol_es_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Recodificar variables
data_wide$part_pol_firma_20_rec = ifelse(data_wide$part_pol_firma_20==1|data_wide$part_pol_firma_20==2,0,1)
data_wide$part_pol_marc_pac_20_rec = ifelse(data_wide$part_pol_marc_pac_20==1|data_wide$part_pol_marc_pac_20==2,0,1)
data_wide$part_pol_marc_dis_20_rec = ifelse(data_wide$part_pol_marc_dis_20==1|data_wide$part_pol_marc_dis_20==2,0,1)
data_wide$part_pol_bloq_20_rec = ifelse(data_wide$part_pol_bloq_20==1|data_wide$part_pol_bloq_20==2,0,1)
data_wide$part_pol_rayar_20_rec = ifelse(data_wide$part_pol_rayar_20==1|data_wide$part_pol_rayar_20==2,0,1)
data_wide$part_pol_toma_20_rec = ifelse(data_wide$part_pol_toma_20==1|data_wide$part_pol_toma_20==2,0,1)
data_wide$part_pol_com_20_rec = ifelse(data_wide$part_pol_com_20==1|data_wide$part_pol_com_20==2,0,1)
data_wide$marcha_amig_20_rec = ifelse(data_wide$marcha_amig_20==1|data_wide$marcha_amig_20==2,0,1)
data_wide$marcha_pad_20_rec = ifelse(data_wide$marcha_pad_20==1|data_wide$marcha_pad_20==2,0,1)
data_wide$marcha_fam_20_rec = ifelse(data_wide$marcha_fam_20==1|data_wide$marcha_fam_20==2,0,1)
data_wide$part_pol_online_info_20_rec = ifelse(data_wide$part_pol_online_info_20==1|data_wide$part_pol_online_info_20==2,0,1)
data_wide$part_pol_online_post_20_rec = ifelse(data_wide$part_pol_online_post_20==1|data_wide$part_pol_online_post_20==2,0,1)
data_wide$part_pol_online_com_20_rec = ifelse(data_wide$part_pol_online_com_20==1|data_wide$part_pol_online_com_20==2,0,1)
data_wide$part_pol_online_seg_20_rec = ifelse(data_wide$part_pol_online_seg_20==1|data_wide$part_pol_online_seg_20==2,0,1)
### Crear variable
data_wide$part_pol_20 = as.numeric(data_wide$part_pol_firma_20_rec + data_wide$part_pol_marc_pac_20_rec + data_wide$part_pol_marc_dis_20_rec + data_wide$part_pol_bloq_20_rec + data_wide$part_pol_rayar_20_rec + data_wide$part_pol_toma_20_rec + data_wide$part_pol_com_20_rec + data_wide$marcha_amig_20_rec + data_wide$marcha_pad_20_rec + data_wide$marcha_fam_20_rec + data_wide$part_pol_online_info_20_rec + data_wide$part_pol_online_post_20_rec + data_wide$part_pol_online_com_20_rec + data_wide$part_pol_online_seg_20_rec)
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_20, na.rm=T),
               psych::describe(data_ed_med$part_pol_20, na.rm=T),
               psych::describe(data_ed_ter$part_pol_20, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_20,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_20,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_20,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_20,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
nivel educativo de la padre") + ylim(0,14)
#part_pol_20_colegio
ggsave(part_pol_20_colegio, file = "../output/graphs/part_pol_20_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_pol_21_1s = as.numeric(data_wide$part_pol_firma.x_rec + data_wide$part_pol_marc_pac_rec + data_wide$part_pol_marc_dis_rec + data_wide$part_pol_bloq_rec + data_wide$part_pol_rayar.x_rec + data_wide$part_pol_toma.x_rec + data_wide$part_pol_com_rec + data_wide$marcha_amig.x_rec + data_wide$marcha_pad.x_rec + data_wide$marcha_fam.x_rec + data_wide$part_pol_online_info_rec + data_wide$part_pol_online_post_rec + data_wide$part_pol_online_com_rec + data_wide$part_pol_online_seg_rec)
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_21_1s, na.rm=T),
               psych::describe(data_ed_med$part_pol_21_1s, na.rm=T),
               psych::describe(data_ed_ter$part_pol_21_1s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_21_1s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_21_1s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_21_1s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_21_1s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
nivel educativo de la padre") + ylim(0,14)
#part_pol_21_1s_colegio
ggsave(part_pol_21_1s_colegio, file = "../output/graphs/part_pol_21_1s_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_pol_21_2s = as.numeric(data_wide$part_pol_firma_21b_rec + data_wide$part_pol_marc_pac_21b_rec + data_wide$part_pol_marc_dis_21b_rec + data_wide$part_pol_bloq_21b_rec + data_wide$part_pol_rayar_21b_rec + data_wide$part_pol_toma_21b_rec + data_wide$part_pol_com_21b_rec + data_wide$marcha_amig_21b_rec + data_wide$marcha_pad_21b_rec + data_wide$marcha_fam_21b_rec + data_wide$part_pol_online_info_21b_rec + data_wide$part_pol_online_post_21b_rec + data_wide$part_pol_online_com_21b_rec + data_wide$part_pol_online_seg_21b_rec)
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_21_2s, na.rm=T),
               psych::describe(data_ed_med$part_pol_21_2s, na.rm=T),
               psych::describe(data_ed_ter$part_pol_21_2s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_21_2s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_21_2s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_21_2s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_21_2s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
nivel educativo de la padre") + ylim(0,14)
#part_pol_21_2s_colegio
ggsave(part_pol_21_2s_colegio, file = "../output/graphs/part_pol_21_2s_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos

Participación política durante 3ro y 4to medio

### Recodificar variables
#se excluye + Participar en una marcha con compañeros del colegio (s2_p_e_05_13)
data_wide$part_pol_marcha_pas_rec = ifelse(data_wide$part_pol_marcha_pas==1|data_wide$part_pol_marcha_pas==2,0,1)
data_wide$part_pol_marcha_dis_rec = ifelse(data_wide$part_pol_marcha_dis==1|data_wide$part_pol_marcha_dis==2,0,1)
data_wide$part_pol_bloqueo_rec = ifelse(data_wide$part_pol_bloqueo==1|data_wide$part_pol_bloqueo==2,0,1)
data_wide$part_pol_rayar.y_rec = ifelse(data_wide$part_pol_rayar.y==1|data_wide$part_pol_rayar.y==2,0,1)
data_wide$part_pol_toma.y_rec = ifelse(data_wide$part_pol_toma.y==1|data_wide$part_pol_toma.y==2,0,1)
data_wide$part_pol_volunt_rec = ifelse(data_wide$part_pol_volunt==1|data_wide$part_pol_volunt==2,0,1)
data_wide$part_pol_firma.y_rec = ifelse(data_wide$part_pol_firma.y==1|data_wide$part_pol_firma.y==2,0,1)
data_wide$marcha_amig.y_rec = ifelse(data_wide$marcha_amig.y==1|data_wide$marcha_amig.y==2,0,1)
data_wide$marcha_pad.y_rec = ifelse(data_wide$marcha_pad.y==1|data_wide$marcha_pad.y==2,0,1)
data_wide$marcha_fam.y_rec = ifelse(data_wide$marcha_fam.y==1|data_wide$marcha_fam.y==2,0,1)
data_wide$part_pol_online_rec = ifelse(data_wide$part_pol_online==1|data_wide$part_pol_online==2,0,1)
data_wide$part_online_post_rec = ifelse(data_wide$part_online_post==1|data_wide$part_online_post==2,0,1)
data_wide$part_online_com_rec = ifelse(data_wide$part_online_com==1|data_wide$part_online_com==2,0,1)
data_wide$part_online_seg_rec = ifelse(data_wide$part_online_seg==1|data_wide$part_online_seg==2,0,1)
### Crear variable
data_wide$part_pol_3y4 = as.numeric(data_wide$part_pol_marcha_pas_rec + data_wide$part_pol_marcha_dis_rec + data_wide$part_pol_bloqueo_rec + data_wide$part_pol_rayar.y_rec + data_wide$part_pol_toma.y_rec + data_wide$part_pol_volunt_rec + data_wide$part_pol_firma.y_rec + data_wide$marcha_amig.y_rec + data_wide$marcha_pad.y_rec + data_wide$marcha_fam.y_rec + data_wide$part_pol_online_rec + data_wide$part_online_post_rec + data_wide$part_online_com_rec + data_wide$part_online_seg_rec)
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padr_poli==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padr_poli==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padr_poli==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padr_poli==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_pol_3y4, na.rm=T),
               psych::describe(data_casi_nunca$part_pol_3y4, na.rm=T),
               psych::describe(data_a_veces$part_pol_3y4, na.rm=T),
               psych::describe(data_frecuent$part_pol_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_pol_3y4,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_pol_3y4,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_pol_3y4,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_pol_3y4,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_pol_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,14)
#part_pol_3y4_colegio
ggsave(part_pol_3y4_colegio, file = "../output/graphs/part_pol_3y4_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Recodificar variables
data_wide$part_pol_firma_21_rec = ifelse(data_wide$part_pol_firma_21==1|data_wide$part_pol_firma_21==2,0,1)
data_wide$part_pol_marc_pac_21_rec = ifelse(data_wide$part_pol_marc_pac_21==1|data_wide$part_pol_marc_pac_21==2,0,1)
data_wide$part_pol_marc_dis_21_rec = ifelse(data_wide$part_pol_marc_dis_21==1|data_wide$part_pol_marc_dis_21==2,0,1)
data_wide$part_pol_bloq_21_rec = ifelse(data_wide$part_pol_bloq_21==1|data_wide$part_pol_bloq_21==2,0,1)
data_wide$part_pol_rayar_21_rec = ifelse(data_wide$part_pol_rayar_21==1|data_wide$part_pol_rayar_21==2,0,1)
data_wide$part_pol_toma_21_rec = ifelse(data_wide$part_pol_toma_21==1|data_wide$part_pol_toma_21==2,0,1)
data_wide$part_pol_com_21_rec = ifelse(data_wide$part_pol_com_21==1|data_wide$part_pol_com_21==2,0,1)
data_wide$marcha_amig_21_rec = ifelse(data_wide$marcha_amig_21==1|data_wide$marcha_amig_21==2,0,1)
data_wide$marcha_pad_21_rec = ifelse(data_wide$marcha_pad_21==1|data_wide$marcha_pad_21==2,0,1)
data_wide$marcha_fam_21_rec = ifelse(data_wide$marcha_fam_21==1|data_wide$marcha_fam_21==2,0,1)
data_wide$part_pol_online_info_21_rec = ifelse(data_wide$part_pol_online_info_21==1|data_wide$part_pol_online_info_21==2,0,1)
data_wide$part_pol_online_post_21_rec = ifelse(data_wide$part_pol_online_post_21==1|data_wide$part_pol_online_post_21==2,0,1)
data_wide$part_pol_online_com_21_rec = ifelse(data_wide$part_pol_online_com_21==1|data_wide$part_pol_online_com_21==2,0,1)
data_wide$part_pol_online_seg_21_rec = ifelse(data_wide$part_pol_online_seg_21==1|data_wide$part_pol_online_seg_21==2,0,1)
### Crear variable
data_wide$part_pol_es = as.numeric(data_wide$part_pol_firma_21_rec + data_wide$part_pol_marc_pac_21_rec + data_wide$part_pol_marc_dis_21_rec + data_wide$part_pol_bloq_21_rec + data_wide$part_pol_rayar_21_rec + data_wide$part_pol_toma_21_rec + data_wide$part_pol_com_21_rec + data_wide$marcha_amig_21_rec + data_wide$marcha_pad_21_rec + data_wide$marcha_fam_21_rec + data_wide$part_pol_online_info_21_rec + data_wide$part_pol_online_post_21_rec + data_wide$part_pol_online_com_21_rec + data_wide$part_pol_online_seg_21_rec)
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_21==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_21==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_21==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_21==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_pol_es, na.rm=T),
               psych::describe(data_casi_nunca$part_pol_es, na.rm=T),
               psych::describe(data_a_veces$part_pol_es, na.rm=T),
               psych::describe(data_frecuent$part_pol_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_pol_es,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_pol_es,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_pol_es,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_pol_es,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_pol_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,14)
#part_pol_es_colegio
ggsave(part_pol_es_colegio, file = "../output/graphs/part_pol_es_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Recodificar variables
data_wide$part_pol_firma_20_rec = ifelse(data_wide$part_pol_firma_20==1|data_wide$part_pol_firma_20==2,0,1)
data_wide$part_pol_marc_pac_20_rec = ifelse(data_wide$part_pol_marc_pac_20==1|data_wide$part_pol_marc_pac_20==2,0,1)
data_wide$part_pol_marc_dis_20_rec = ifelse(data_wide$part_pol_marc_dis_20==1|data_wide$part_pol_marc_dis_20==2,0,1)
data_wide$part_pol_bloq_20_rec = ifelse(data_wide$part_pol_bloq_20==1|data_wide$part_pol_bloq_20==2,0,1)
data_wide$part_pol_rayar_20_rec = ifelse(data_wide$part_pol_rayar_20==1|data_wide$part_pol_rayar_20==2,0,1)
data_wide$part_pol_toma_20_rec = ifelse(data_wide$part_pol_toma_20==1|data_wide$part_pol_toma_20==2,0,1)
data_wide$part_pol_com_20_rec = ifelse(data_wide$part_pol_com_20==1|data_wide$part_pol_com_20==2,0,1)
data_wide$marcha_amig_20_rec = ifelse(data_wide$marcha_amig_20==1|data_wide$marcha_amig_20==2,0,1)
data_wide$marcha_pad_20_rec = ifelse(data_wide$marcha_pad_20==1|data_wide$marcha_pad_20==2,0,1)
data_wide$marcha_fam_20_rec = ifelse(data_wide$marcha_fam_20==1|data_wide$marcha_fam_20==2,0,1)
data_wide$part_pol_online_info_20_rec = ifelse(data_wide$part_pol_online_info_20==1|data_wide$part_pol_online_info_20==2,0,1)
data_wide$part_pol_online_post_20_rec = ifelse(data_wide$part_pol_online_post_20==1|data_wide$part_pol_online_post_20==2,0,1)
data_wide$part_pol_online_com_20_rec = ifelse(data_wide$part_pol_online_com_20==1|data_wide$part_pol_online_com_20==2,0,1)
data_wide$part_pol_online_seg_20_rec = ifelse(data_wide$part_pol_online_seg_20==1|data_wide$part_pol_online_seg_20==2,0,1)
### Crear variable
data_wide$part_pol_20 = as.numeric(data_wide$part_pol_firma_20_rec + data_wide$part_pol_marc_pac_20_rec + data_wide$part_pol_marc_dis_20_rec + data_wide$part_pol_bloq_20_rec + data_wide$part_pol_rayar_20_rec + data_wide$part_pol_toma_20_rec + data_wide$part_pol_com_20_rec + data_wide$marcha_amig_20_rec + data_wide$marcha_pad_20_rec + data_wide$marcha_fam_20_rec + data_wide$part_pol_online_info_20_rec + data_wide$part_pol_online_post_20_rec + data_wide$part_pol_online_com_20_rec + data_wide$part_pol_online_seg_20_rec)
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_20==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_20==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_20==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_20==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_pol_20, na.rm=T),
               psych::describe(data_casi_nunca$part_pol_20, na.rm=T),
               psych::describe(data_a_veces$part_pol_20, na.rm=T),
               psych::describe(data_frecuent$part_pol_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_pol_20,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_pol_20,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_pol_20,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_pol_20,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_pol_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,14)
#part_pol_20_colegio
ggsave(part_pol_20_colegio, file = "../output/graphs/part_pol_20_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_pol_21_1s = as.numeric(data_wide$part_pol_firma.x_rec + data_wide$part_pol_marc_pac_rec + data_wide$part_pol_marc_dis_rec + data_wide$part_pol_bloq_rec + data_wide$part_pol_rayar.x_rec + data_wide$part_pol_toma.x_rec + data_wide$part_pol_com_rec + data_wide$marcha_amig.x_rec + data_wide$marcha_pad.x_rec + data_wide$marcha_fam.x_rec + data_wide$part_pol_online_info_rec + data_wide$part_pol_online_post_rec + data_wide$part_pol_online_com_rec + data_wide$part_pol_online_seg_rec)
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_pol_21_1s, na.rm=T),
               psych::describe(data_casi_nunca$part_pol_21_1s, na.rm=T),
               psych::describe(data_a_veces$part_pol_21_1s, na.rm=T),
               psych::describe(data_frecuent$part_pol_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_pol_21_1s,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_pol_21_1s,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_pol_21_1s,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_pol_21_1s,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_pol_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,14)
#part_pol_21_1s_colegio
ggsave(part_pol_21_1s_colegio, file = "../output/graphs/part_pol_21_1s_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_pol_21_2s = as.numeric(data_wide$part_pol_firma_21b_rec + data_wide$part_pol_marc_pac_21b_rec + data_wide$part_pol_marc_dis_21b_rec + data_wide$part_pol_bloq_21b_rec + data_wide$part_pol_rayar_21b_rec + data_wide$part_pol_toma_21b_rec + data_wide$part_pol_com_21b_rec + data_wide$marcha_amig_21b_rec + data_wide$marcha_pad_21b_rec + data_wide$marcha_fam_21b_rec + data_wide$part_pol_online_info_21b_rec + data_wide$part_pol_online_post_21b_rec + data_wide$part_pol_online_com_21b_rec + data_wide$part_pol_online_seg_21b_rec)
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_21b==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_21b==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_21b==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_21b==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_pol_21_2s, na.rm=T),
               psych::describe(data_casi_nunca$part_pol_21_2s, na.rm=T),
               psych::describe(data_a_veces$part_pol_21_2s, na.rm=T),
               psych::describe(data_frecuent$part_pol_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_pol_21_2s,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_pol_21_2s,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_pol_21_2s,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_pol_21_2s,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_pol_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en la diversificación de repertorios de 
participación (escala de 0 a 14)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Diversificación de repertorios de participación por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,14)
#part_pol_21_2s_colegio
ggsave(part_pol_21_2s_colegio, file = "../output/graphs/part_pol_21_2s_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Activismo no disruptivo

Dependencia administrativa establecimiento

Participación política durante 3ro y 4to medio

### Crear variable
#data_wide$part_act_no_dis_3y4 <- as.numeric(data_wide$part_pol_firma.y + data_wide$part_pol_marcha_pas)/2
data_wide$part_act_no_dis_3y4 <- as.numeric(data_wide$part_pol_marcha_pas)
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_no_dis_3y4, na.rm=T),
               psych::describe(data_sub$part_act_no_dis_3y4, na.rm=T),psych::describe(data_priv$part_act_no_dis_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)
pond1 <- stats::weighted.mean(x=data_mun$part_act_no_dis_3y4,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_no_dis_3y4,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_no_dis_3y4,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_no_dis_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_no_dis_3y4_colegio
ggsave(part_act_no_dis_3y4_colegio, file = "../output/graphs/part_act_no_dis_3y4_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
#data_wide$part_act_no_dis_es <- as.numeric(data_wide$part_pol_firma_21 + data_wide$part_pol_marc_pac_21)/2
data_wide$part_act_no_dis_es <- as.numeric(data_wide$part_pol_marc_pac_21)
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_no_dis_es, na.rm=T),
               psych::describe(data_sub$part_act_no_dis_es, na.rm=T),psych::describe(data_priv$part_act_no_dis_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_no_dis_es,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_no_dis_es,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_no_dis_es,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_no_dis_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_no_dis_es_colegio
ggsave(part_act_no_dis_es_colegio, file = "../output/graphs/part_act_no_dis_es_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
#data_wide$part_act_no_dis_20 = as.numeric(data_wide$part_pol_firma_20 + data_wide$part_pol_marc_pac_20)/2
data_wide$part_act_no_dis_20 = as.numeric(data_wide$part_pol_marc_pac_20)
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_no_dis_20, na.rm=T),
               psych::describe(data_sub$part_act_no_dis_20, na.rm=T),psych::describe(data_priv$part_act_no_dis_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_no_dis_20,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_no_dis_20,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_no_dis_20,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_no_dis_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
          ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') +  
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_no_dis_20_colegio
ggsave(part_act_no_dis_20_colegio, file = "../output/graphs/part_act_no_dis_20_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
#data_wide$part_act_no_dis_21_1s = as.numeric(data_wide$part_pol_firma.x + data_wide$part_pol_marc_pac)/2
data_wide$part_act_no_dis_21_1s = as.numeric(data_wide$part_pol_marc_pac)
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_no_dis_21_1s, na.rm=T),
               psych::describe(data_sub$part_act_no_dis_21_1s, na.rm=T),psych::describe(data_priv$part_act_no_dis_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_no_dis_21_1s,y=data_mun$weight_w02,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_no_dis_21_1s,y=data_sub$weight_w02,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_no_dis_21_1s,y=data_priv$weight_w02,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_no_dis_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_no_dis_21_1s_colegio
ggsave(part_act_no_dis_21_1s_colegio, file = "../output/graphs/part_act_no_dis_21_1s_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
#data_wide$part_act_no_dis_21_2s = as.numeric(data_wide$part_pol_firma_21b + data_wide$part_pol_marc_pac_21b)/2
data_wide$part_act_no_dis_21_2s = as.numeric(data_wide$part_pol_marc_pac_21b)
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_no_dis_21_2s, na.rm=T),
               psych::describe(data_sub$part_act_no_dis_21_2s, na.rm=T),psych::describe(data_priv$part_act_no_dis_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_no_dis_21_2s,y=data_mun$weight_w03,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_no_dis_21_2s,y=data_sub$weight_w03,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_no_dis_21_2s,y=data_priv$weight_w03,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_no_dis_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_no_dis_21_2s_colegio
ggsave(part_act_no_dis_21_2s_colegio, file = "../output/graphs/part_act_no_dis_21_2s_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_no_dis_3y4 <- as.numeric(data_wide$part_pol_firma.y + data_wide$part_pol_marcha_pas)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_no_dis_3y4, na.rm=T),
               psych::describe(data_ed_med$part_act_no_dis_3y4, na.rm=T),
               psych::describe(data_ed_ter$part_act_no_dis_3y4, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_no_dis_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_no_dis_3y4,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_no_dis_3y4,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_no_dis_3y4,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_no_dis_3y4,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_no_dis_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
nivel educativo de la madre") + ylim(0,4)
#part_act_no_dis_3y4_colegio
ggsave(part_act_no_dis_3y4_colegio, file = "../output/graphs/part_act_no_dis_3y4_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_no_dis_es <- as.numeric(data_wide$part_pol_firma_21 + data_wide$part_pol_marc_pac_21)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_no_dis_es, na.rm=T),
               psych::describe(data_ed_med$part_act_no_dis_es, na.rm=T),
               psych::describe(data_ed_ter$part_act_no_dis_es, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_no_dis_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_no_dis_es,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_no_dis_es,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_no_dis_es,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_no_dis_es,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_no_dis_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
nivel educativo de la madre") + ylim(0,4)
#part_act_no_dis_es_colegio
ggsave(part_act_no_dis_es_colegio, file = "../output/graphs/part_act_no_dis_es_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_no_dis_20 = as.numeric(data_wide$part_pol_firma_20 + data_wide$part_pol_marc_pac_20)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_no_dis_20, na.rm=T),
               psych::describe(data_ed_med$part_act_no_dis_20, na.rm=T),
               psych::describe(data_ed_ter$part_act_no_dis_20, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_no_dis_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_no_dis_20,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_no_dis_20,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_no_dis_20,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_no_dis_20,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_no_dis_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
nivel educativo de la madre") + ylim(0,4)
#part_act_no_dis_20_colegio
ggsave(part_act_no_dis_20_colegio, file = "../output/graphs/part_act_no_dis_20_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_no_dis_21_1s = as.numeric(data_wide$part_pol_firma.x + data_wide$part_pol_marc_pac)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_no_dis_21_1s, na.rm=T),
               psych::describe(data_ed_med$part_act_no_dis_21_1s, na.rm=T),
               psych::describe(data_ed_ter$part_act_no_dis_21_1s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_no_dis_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_no_dis_21_1s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_no_dis_21_1s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_no_dis_21_1s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_no_dis_21_1s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_no_dis_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
nivel educativo de la madre") + ylim(0,4)
#part_act_no_dis_21_1s_colegio
ggsave(part_act_no_dis_21_1s_colegio, file = "../output/graphs/part_act_no_dis_21_1s_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_act_no_dis_21_2s = as.numeric(data_wide$part_pol_firma_21b + data_wide$part_pol_marc_pac_21b)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_no_dis_21_2s, na.rm=T),
               psych::describe(data_ed_med$part_act_no_dis_21_2s, na.rm=T),
               psych::describe(data_ed_ter$part_act_no_dis_21_2s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_no_dis_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_no_dis_21_2s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_no_dis_21_2s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_no_dis_21_2s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_no_dis_21_2s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_no_dis_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
nivel educativo de la madre") + ylim(0,4)
#part_act_no_dis_21_2s_colegio
ggsave(part_act_no_dis_21_2s_colegio, file = "../output/graphs/part_act_no_dis_21_2s_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_no_dis_3y4 <- as.numeric(data_wide$part_pol_firma.y + data_wide$part_pol_marcha_pas)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_no_dis_3y4, na.rm=T),
               psych::describe(data_ed_med$part_act_no_dis_3y4, na.rm=T),
               psych::describe(data_ed_ter$part_act_no_dis_3y4, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_no_dis_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_no_dis_3y4,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_no_dis_3y4,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_no_dis_3y4,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_no_dis_3y4,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_no_dis_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
nivel educativo de la padre") + ylim(0,4)
#part_act_no_dis_3y4_colegio
ggsave(part_act_no_dis_3y4_colegio, file = "../output/graphs/part_act_no_dis_3y4_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_no_dis_es <- as.numeric(data_wide$part_pol_firma_21 + data_wide$part_pol_marc_pac_21)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_no_dis_es, na.rm=T),
               psych::describe(data_ed_med$part_act_no_dis_es, na.rm=T),
               psych::describe(data_ed_ter$part_act_no_dis_es, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_no_dis_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_no_dis_es,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_no_dis_es,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_no_dis_es,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_no_dis_es,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_no_dis_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
nivel educativo de la padre") + ylim(0,4)
#part_act_no_dis_es_colegio
ggsave(part_act_no_dis_es_colegio, file = "../output/graphs/part_act_no_dis_es_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_no_dis_20 = as.numeric(data_wide$part_pol_firma_20 + data_wide$part_pol_marc_pac_20)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_no_dis_20, na.rm=T),
               psych::describe(data_ed_med$part_act_no_dis_20, na.rm=T),
               psych::describe(data_ed_ter$part_act_no_dis_20, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_no_dis_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_no_dis_20,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_no_dis_20,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_no_dis_20,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_no_dis_20,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_no_dis_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
nivel educativo de la padre") + ylim(0,4)
#part_act_no_dis_20_colegio
ggsave(part_act_no_dis_20_colegio, file = "../output/graphs/part_act_no_dis_20_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_no_dis_21_1s = as.numeric(data_wide$part_pol_firma.x + data_wide$part_pol_marc_pac)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_no_dis_21_1s, na.rm=T),
               psych::describe(data_ed_med$part_act_no_dis_21_1s, na.rm=T),
               psych::describe(data_ed_ter$part_act_no_dis_21_1s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_no_dis_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_no_dis_21_1s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_no_dis_21_1s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_no_dis_21_1s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_no_dis_21_1s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_no_dis_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
nivel educativo de la padre") + ylim(0,4)
#part_act_no_dis_21_1s_colegio
ggsave(part_act_no_dis_21_1s_colegio, file = "../output/graphs/part_act_no_dis_21_1s_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_act_no_dis_21_2s = as.numeric(data_wide$part_pol_firma_21b + data_wide$part_pol_marc_pac_21b)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_no_dis_21_2s, na.rm=T),
               psych::describe(data_ed_med$part_act_no_dis_21_2s, na.rm=T),
               psych::describe(data_ed_ter$part_act_no_dis_21_2s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_no_dis_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_no_dis_21_2s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_no_dis_21_2s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_no_dis_21_2s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_no_dis_21_2s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_no_dis_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
nivel educativo de la padre") + ylim(0,4)
#part_act_no_dis_21_2s_colegio
ggsave(part_act_no_dis_21_2s_colegio, file = "../output/graphs/part_act_no_dis_21_2s_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_no_dis_3y4 <- as.numeric(data_wide$part_pol_firma.y + data_wide$part_pol_marcha_pas)/2
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padr_poli==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padr_poli==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padr_poli==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padr_poli==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_no_dis_3y4, na.rm=T),
               psych::describe(data_casi_nunca$part_act_no_dis_3y4, na.rm=T),
               psych::describe(data_a_veces$part_act_no_dis_3y4, na.rm=T),
               psych::describe(data_frecuent$part_act_no_dis_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_no_dis_3y4,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_no_dis_3y4,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_no_dis_3y4,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_no_dis_3y4,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_no_dis_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_no_dis_3y4_colegio
ggsave(part_act_no_dis_3y4_colegio, file = "../output/graphs/part_act_no_dis_3y4_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_no_dis_es <- as.numeric(data_wide$part_pol_firma_21 + data_wide$part_pol_marc_pac_21)/2
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_21==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_21==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_21==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_21==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_no_dis_es, na.rm=T),
               psych::describe(data_casi_nunca$part_act_no_dis_es, na.rm=T),
               psych::describe(data_a_veces$part_act_no_dis_es, na.rm=T),
               psych::describe(data_frecuent$part_act_no_dis_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_no_dis_es,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_no_dis_es,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_no_dis_es,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_no_dis_es,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_no_dis_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_no_dis_es_colegio
ggsave(part_act_no_dis_es_colegio, file = "../output/graphs/part_act_no_dis_es_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_no_dis_20 = as.numeric(data_wide$part_pol_firma_20 + data_wide$part_pol_marc_pac_20)/2
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_20==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_20==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_20==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_20==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_no_dis_20, na.rm=T),
               psych::describe(data_casi_nunca$part_act_no_dis_20, na.rm=T),
               psych::describe(data_a_veces$part_act_no_dis_20, na.rm=T),
               psych::describe(data_frecuent$part_act_no_dis_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_no_dis_20,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_no_dis_20,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_no_dis_20,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_no_dis_20,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_no_dis_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_no_dis_20_colegio
ggsave(part_act_no_dis_20_colegio, file = "../output/graphs/part_act_no_dis_20_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_no_dis_21_1s = as.numeric(data_wide$part_pol_firma.x + data_wide$part_pol_marc_pac)/2
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_no_dis_21_1s, na.rm=T),
               psych::describe(data_casi_nunca$part_act_no_dis_21_1s, na.rm=T),
               psych::describe(data_a_veces$part_act_no_dis_21_1s, na.rm=T),
               psych::describe(data_frecuent$part_act_no_dis_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_no_dis_21_1s,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_no_dis_21_1s,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_no_dis_21_1s,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_no_dis_21_1s,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_no_dis_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_no_dis_21_1s_colegio
ggsave(part_act_no_dis_21_1s_colegio, file = "../output/graphs/part_act_no_dis_21_1s_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_act_no_dis_21_2s = as.numeric(data_wide$part_pol_firma_21b + data_wide$part_pol_marc_pac_21b)/2
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_21b==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_21b==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_21b==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_21b==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_no_dis_21_2s, na.rm=T),
               psych::describe(data_casi_nunca$part_act_no_dis_21_2s, na.rm=T),
               psych::describe(data_a_veces$part_act_no_dis_21_2s, na.rm=T),
               psych::describe(data_frecuent$part_act_no_dis_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_no_dis_21_2s,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_no_dis_21_2s,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_no_dis_21_2s,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_no_dis_21_2s,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_no_dis_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
no disruptiva (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista no disruptiva por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_no_dis_21_2s_colegio
ggsave(part_act_no_dis_21_2s_colegio, file = "../output/graphs/part_act_no_dis_21_2s_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Activismo disruptivo

Dependencia administrativa establecimiento

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_dis_3y4 <- as.numeric(data_wide$part_pol_marcha_dis + data_wide$part_pol_bloqueo + data_wide$part_pol_rayar.y + data_wide$part_pol_toma.y)/4
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_dis_3y4, na.rm=T),
               psych::describe(data_sub$part_act_dis_3y4, na.rm=T),psych::describe(data_priv$part_act_dis_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)
pond1 <- stats::weighted.mean(x=data_mun$part_act_dis_3y4,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_dis_3y4,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_dis_3y4,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_dis_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_dis_3y4_colegio
ggsave(part_act_dis_3y4_colegio, file = "../output/graphs/part_act_dis_3y4_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_dis_es <- as.numeric(data_wide$part_pol_marc_dis_21 + data_wide$part_pol_bloq_21 + data_wide$part_pol_rayar_21 + data_wide$part_pol_toma_21)/4
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_dis_es, na.rm=T),
               psych::describe(data_sub$part_act_dis_es, na.rm=T),psych::describe(data_priv$part_act_dis_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_dis_es,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_dis_es,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_dis_es,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_dis_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_dis_es_colegio
ggsave(part_act_dis_es_colegio, file = "../output/graphs/part_act_dis_es_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_dis_20 = as.numeric(data_wide$part_pol_marc_dis_20 + data_wide$part_pol_bloq_20 + data_wide$part_pol_rayar_20 + data_wide$part_pol_toma_20)/4
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_dis_20, na.rm=T),
               psych::describe(data_sub$part_act_dis_20, na.rm=T),psych::describe(data_priv$part_act_dis_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_dis_20,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_dis_20,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_dis_20,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_dis_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_dis_20_colegio
ggsave(part_act_dis_20_colegio, file = "../output/graphs/part_act_dis_20_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_dis_21_1s = as.numeric(data_wide$part_pol_marcha_dis + data_wide$part_pol_bloq + data_wide$part_pol_rayar.x + data_wide$part_pol_toma.x)/4
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_dis_21_1s, na.rm=T),
               psych::describe(data_sub$part_act_dis_21_1s, na.rm=T),psych::describe(data_priv$part_act_dis_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_dis_21_1s,y=data_mun$weight_w02,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_dis_21_1s,y=data_sub$weight_w02,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_dis_21_1s,y=data_priv$weight_w02,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_dis_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_dis_21_1s_colegio
ggsave(part_act_dis_21_1s_colegio, file = "../output/graphs/part_act_dis_21_1s_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_act_dis_21_2s = as.numeric(data_wide$part_pol_marc_dis_21b + data_wide$part_pol_bloq_21b + data_wide$part_pol_rayar_21b + data_wide$part_pol_toma_21b)/4
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_dis_21_2s, na.rm=T),
               psych::describe(data_sub$part_act_dis_21_2s, na.rm=T),psych::describe(data_priv$part_act_dis_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_dis_21_2s,y=data_mun$weight_w03,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_dis_21_2s,y=data_sub$weight_w03,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_dis_21_2s,y=data_priv$weight_w03,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_dis_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_dis_21_2s_colegio
ggsave(part_act_dis_21_2s_colegio, file = "../output/graphs/part_act_dis_21_2s_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_dis_3y4 <- as.numeric(data_wide$part_pol_marcha_dis + data_wide$part_pol_bloqueo + data_wide$part_pol_rayar.y + data_wide$part_pol_toma.y)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_dis_3y4, na.rm=T),
               psych::describe(data_ed_med$part_act_dis_3y4, na.rm=T),
               psych::describe(data_ed_ter$part_act_dis_3y4, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_dis_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_dis_3y4,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_dis_3y4,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_dis_3y4,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_dis_3y4,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_dis_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
nivel educativo de la madre") + ylim(0,4)
#part_act_dis_3y4_colegio
ggsave(part_act_dis_3y4_colegio, file = "../output/graphs/part_act_dis_3y4_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_dis_es <- as.numeric(data_wide$part_pol_marc_dis_21 + data_wide$part_pol_bloq_21 + data_wide$part_pol_rayar_21 + data_wide$part_pol_toma_21)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_dis_es, na.rm=T),
               psych::describe(data_ed_med$part_act_dis_es, na.rm=T),
               psych::describe(data_ed_ter$part_act_dis_es, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_dis_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_dis_es,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_dis_es,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_dis_es,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_dis_es,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_dis_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
nivel educativo de la madre") + ylim(0,4)
#part_act_dis_es_colegio
ggsave(part_act_dis_es_colegio, file = "../output/graphs/part_act_dis_es_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_dis_20 = as.numeric(data_wide$part_pol_marc_dis_20 + data_wide$part_pol_bloq_20 + data_wide$part_pol_rayar_20 + data_wide$part_pol_toma_20)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_dis_20, na.rm=T),
               psych::describe(data_ed_med$part_act_dis_20, na.rm=T),
               psych::describe(data_ed_ter$part_act_dis_20, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_dis_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_dis_20,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_dis_20,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_dis_20,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_dis_20,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_dis_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
nivel educativo de la madre") + ylim(0,4)
#part_act_dis_20_colegio
ggsave(part_act_dis_20_colegio, file = "../output/graphs/part_act_dis_20_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_dis_21_1s = as.numeric(data_wide$part_pol_marcha_dis + data_wide$part_pol_bloq + data_wide$part_pol_rayar.x + data_wide$part_pol_toma.x)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_dis_21_1s, na.rm=T),
               psych::describe(data_ed_med$part_act_dis_21_1s, na.rm=T),
               psych::describe(data_ed_ter$part_act_dis_21_1s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_dis_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_dis_21_1s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_dis_21_1s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_dis_21_1s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_dis_21_1s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_dis_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
nivel educativo de la madre") + ylim(0,4)
#part_act_dis_21_1s_colegio
ggsave(part_act_dis_21_1s_colegio, file = "../output/graphs/part_act_dis_21_1s_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_act_dis_21_2s = as.numeric(data_wide$part_pol_marc_dis_21b + data_wide$part_pol_bloq_21b + data_wide$part_pol_rayar_21b + data_wide$part_pol_toma_21b)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_dis_21_2s, na.rm=T),
               psych::describe(data_ed_med$part_act_dis_21_2s, na.rm=T),
               psych::describe(data_ed_ter$part_act_dis_21_2s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_dis_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_dis_21_2s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_dis_21_2s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_dis_21_2s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_dis_21_2s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_dis_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
nivel educativo de la madre") + ylim(0,4)
#part_act_dis_21_2s_colegio
ggsave(part_act_dis_21_2s_colegio, file = "../output/graphs/part_act_dis_21_2s_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_dis_3y4 <- as.numeric(data_wide$part_pol_marcha_dis + data_wide$part_pol_bloqueo + data_wide$part_pol_rayar.y + data_wide$part_pol_toma.y)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_dis_3y4, na.rm=T),
               psych::describe(data_ed_med$part_act_dis_3y4, na.rm=T),
               psych::describe(data_ed_ter$part_act_dis_3y4, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_dis_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_dis_3y4,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_dis_3y4,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_dis_3y4,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_dis_3y4,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_dis_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
nivel educativo de la padre") + ylim(0,4)
#part_act_dis_3y4_colegio
ggsave(part_act_dis_3y4_colegio, file = "../output/graphs/part_act_dis_3y4_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_dis_es <- as.numeric(data_wide$part_pol_marc_dis_21 + data_wide$part_pol_bloq_21 + data_wide$part_pol_rayar_21 + data_wide$part_pol_toma_21)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_dis_es, na.rm=T),
               psych::describe(data_ed_med$part_act_dis_es, na.rm=T),
               psych::describe(data_ed_ter$part_act_dis_es, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_dis_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_dis_es,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_dis_es,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_dis_es,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_dis_es,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_dis_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
nivel educativo de la padre") + ylim(0,4)
#part_act_dis_es_colegio
ggsave(part_act_dis_es_colegio, file = "../output/graphs/part_act_dis_es_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_dis_20 = as.numeric(data_wide$part_pol_marc_dis_20 + data_wide$part_pol_bloq_20 + data_wide$part_pol_rayar_20 + data_wide$part_pol_toma_20)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_dis_20, na.rm=T),
               psych::describe(data_ed_med$part_act_dis_20, na.rm=T),
               psych::describe(data_ed_ter$part_act_dis_20, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_dis_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_dis_20,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_dis_20,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_dis_20,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_dis_20,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_dis_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
nivel educativo de la padre") + ylim(0,4)
#part_act_dis_20_colegio
ggsave(part_act_dis_20_colegio, file = "../output/graphs/part_act_dis_20_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_dis_21_1s = as.numeric(data_wide$part_pol_marcha_dis + data_wide$part_pol_bloq + data_wide$part_pol_rayar.x + data_wide$part_pol_toma.x)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_dis_21_1s, na.rm=T),
               psych::describe(data_ed_med$part_act_dis_21_1s, na.rm=T),
               psych::describe(data_ed_ter$part_act_dis_21_1s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_dis_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_dis_21_1s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_dis_21_1s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_dis_21_1s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_dis_21_1s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_dis_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
nivel educativo de la padre") + ylim(0,4)
#part_act_dis_21_1s_colegio
ggsave(part_act_dis_21_1s_colegio, file = "../output/graphs/part_act_dis_21_1s_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_act_dis_21_2s = as.numeric(data_wide$part_pol_marc_dis_21b + data_wide$part_pol_bloq_21b + data_wide$part_pol_rayar_21b + data_wide$part_pol_toma_21b)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_dis_21_2s, na.rm=T),
               psych::describe(data_ed_med$part_act_dis_21_2s, na.rm=T),
               psych::describe(data_ed_ter$part_act_dis_21_2s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_dis_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_dis_21_2s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_dis_21_2s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_dis_21_2s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_dis_21_2s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_dis_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
nivel educativo de la padre") + ylim(0,4)
#part_act_dis_21_2s_colegio
ggsave(part_act_dis_21_2s_colegio, file = "../output/graphs/part_act_dis_21_2s_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_dis_3y4 <- as.numeric(data_wide$part_pol_marcha_dis + data_wide$part_pol_bloqueo + data_wide$part_pol_rayar.y + data_wide$part_pol_toma.y)/4
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padr_poli==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padr_poli==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padr_poli==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padr_poli==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_dis_3y4, na.rm=T),
               psych::describe(data_casi_nunca$part_act_dis_3y4, na.rm=T),
               psych::describe(data_a_veces$part_act_dis_3y4, na.rm=T),
               psych::describe(data_frecuent$part_act_dis_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_dis_3y4,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_dis_3y4,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_dis_3y4,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_dis_3y4,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_dis_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_dis_3y4_colegio
ggsave(part_act_dis_3y4_colegio, file = "../output/graphs/part_act_dis_3y4_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_dis_es <- as.numeric(data_wide$part_pol_marc_dis_21 + data_wide$part_pol_bloq_21 + data_wide$part_pol_rayar_21 + data_wide$part_pol_toma_21)/4
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_21==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_21==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_21==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_21==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_dis_es, na.rm=T),
               psych::describe(data_casi_nunca$part_act_dis_es, na.rm=T),
               psych::describe(data_a_veces$part_act_dis_es, na.rm=T),
               psych::describe(data_frecuent$part_act_dis_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_dis_es,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_dis_es,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_dis_es,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_dis_es,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_dis_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_dis_es_colegio
ggsave(part_act_dis_es_colegio, file = "../output/graphs/part_act_dis_es_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_dis_20 = as.numeric(data_wide$part_pol_marc_dis_20 + data_wide$part_pol_bloq_20 + data_wide$part_pol_rayar_20 + data_wide$part_pol_toma_20)/4
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_20==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_20==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_20==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_20==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_dis_20, na.rm=T),
               psych::describe(data_casi_nunca$part_act_dis_20, na.rm=T),
               psych::describe(data_a_veces$part_act_dis_20, na.rm=T),
               psych::describe(data_frecuent$part_act_dis_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_dis_20,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_dis_20,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_dis_20,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_dis_20,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_dis_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_dis_20_colegio
ggsave(part_act_dis_20_colegio, file = "../output/graphs/part_act_dis_20_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_dis_21_1s = as.numeric(data_wide$part_pol_marcha_dis + data_wide$part_pol_bloq + data_wide$part_pol_rayar.x + data_wide$part_pol_toma.x)/4
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_dis_21_1s, na.rm=T),
               psych::describe(data_casi_nunca$part_act_dis_21_1s, na.rm=T),
               psych::describe(data_a_veces$part_act_dis_21_1s, na.rm=T),
               psych::describe(data_frecuent$part_act_dis_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_dis_21_1s,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_dis_21_1s,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_dis_21_1s,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_dis_21_1s,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_dis_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_dis_21_1s_colegio
ggsave(part_act_dis_21_1s_colegio, file = "../output/graphs/part_act_dis_21_1s_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_act_dis_21_2s = as.numeric(data_wide$part_pol_marc_dis_21b + data_wide$part_pol_bloq_21b + data_wide$part_pol_rayar_21b + data_wide$part_pol_toma_21b)/4
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_21b==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_21b==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_21b==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_21b==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_dis_21_2s, na.rm=T),
               psych::describe(data_casi_nunca$part_act_dis_21_2s, na.rm=T),
               psych::describe(data_a_veces$part_act_dis_21_2s, na.rm=T),
               psych::describe(data_frecuent$part_act_dis_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_dis_21_2s,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_dis_21_2s,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_dis_21_2s,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_dis_21_2s,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_dis_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
disruptiva (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista disruptiva por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_dis_21_2s_colegio
ggsave(part_act_dis_21_2s_colegio, file = "../output/graphs/part_act_dis_21_2s_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Activismo online

Dependencia administrativa establecimiento

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_online_3y4 <- as.numeric(data_wide$part_pol_online + data_wide$part_online_post + data_wide$part_online_com + data_wide$part_online_seg)/4
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_online_3y4, na.rm=T),
               psych::describe(data_sub$part_act_online_3y4, na.rm=T),psych::describe(data_priv$part_act_online_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)
pond1 <- stats::weighted.mean(x=data_mun$part_act_online_3y4,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_online_3y4,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_online_3y4,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_online_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_online_3y4_colegio
ggsave(part_act_online_3y4_colegio, file = "../output/graphs/part_act_online_3y4_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_online_es <- as.numeric(data_wide$part_pol_online_info_21 + data_wide$part_pol_online_post_21 + data_wide$part_pol_online_com_21 + data_wide$part_pol_online_seg_21)/4
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_online_es, na.rm=T),
               psych::describe(data_sub$part_act_online_es, na.rm=T),psych::describe(data_priv$part_act_online_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_online_es,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_online_es,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_online_es,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_online_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_online_es_colegio
ggsave(part_act_online_es_colegio, file = "../output/graphs/part_act_online_es_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_online_20 = as.numeric(data_wide$part_pol_online_info_20 + data_wide$part_pol_online_post_20 + data_wide$part_pol_online_com_20 + data_wide$part_pol_online_seg_20   )/4
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_online_20, na.rm=T),
               psych::describe(data_sub$part_act_online_20, na.rm=T),psych::describe(data_priv$part_act_online_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_online_20,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_online_20,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_online_20,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_online_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_online_20_colegio
ggsave(part_act_online_20_colegio, file = "../output/graphs/part_act_online_20_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_online_21_1s = as.numeric(data_wide$part_pol_online_info + data_wide$part_pol_online_post + data_wide$part_pol_online_com + data_wide$part_pol_online_seg)/4
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_online_21_1s, na.rm=T),
               psych::describe(data_sub$part_act_online_21_1s, na.rm=T),psych::describe(data_priv$part_act_online_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_online_21_1s,y=data_mun$weight_w02,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_online_21_1s,y=data_sub$weight_w02,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_online_21_1s,y=data_priv$weight_w02,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_online_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_online_21_1s_colegio
ggsave(part_act_online_21_1s_colegio, file = "../output/graphs/part_act_online_21_1s_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable 
data_wide$part_act_online_21_2s = as.numeric(data_wide$part_pol_online_info_21b + data_wide$part_pol_online_post_21b + data_wide$part_pol_online_com_21b + data_wide$part_pol_online_seg_21b)/4
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_act_online_21_2s, na.rm=T),
               psych::describe(data_sub$part_act_online_21_2s, na.rm=T),psych::describe(data_priv$part_act_online_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_act_online_21_2s,y=data_mun$weight_w03,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_act_online_21_2s,y=data_sub$weight_w03,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_act_online_21_2s,y=data_priv$weight_w03,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_act_online_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_act_online_21_2s_colegio
ggsave(part_act_online_21_2s_colegio, file = "../output/graphs/part_act_online_21_2s_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_online_3y4 <- as.numeric(data_wide$part_pol_online + data_wide$part_online_post + data_wide$part_online_com + data_wide$part_online_seg)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_online_3y4, na.rm=T),
               psych::describe(data_ed_med$part_act_online_3y4, na.rm=T),
               psych::describe(data_ed_ter$part_act_online_3y4, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_online_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_online_3y4,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_online_3y4,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_online_3y4,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_online_3y4,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_online_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
nivel educativo de la madre") + ylim(0,4)
#part_act_online_3y4_colegio
ggsave(part_act_online_3y4_colegio, file = "../output/graphs/part_act_online_3y4_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_online_es <- as.numeric(data_wide$part_pol_online_info_21 + data_wide$part_pol_online_post_21 + data_wide$part_pol_online_com_21 + data_wide$part_pol_online_seg_21)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_online_es, na.rm=T),
               psych::describe(data_ed_med$part_act_online_es, na.rm=T),
               psych::describe(data_ed_ter$part_act_online_es, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_online_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_online_es,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_online_es,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_online_es,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_online_es,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_online_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
nivel educativo de la madre") + ylim(0,4)
#part_act_online_es_colegio
ggsave(part_act_online_es_colegio, file = "../output/graphs/part_act_online_es_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_online_20 = as.numeric(data_wide$part_pol_online_info_20 + data_wide$part_pol_online_post_20 + data_wide$part_pol_online_com_20 + data_wide$part_pol_online_seg_20   )/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)```
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_online_20, na.rm=T),
               psych::describe(data_ed_med$part_act_online_20, na.rm=T),
               psych::describe(data_ed_ter$part_act_online_20, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_online_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_online_20,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_online_20,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_online_20,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_online_20,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_online_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
nivel educativo de la madre") + ylim(0,4)
#part_act_online_20_colegio
ggsave(part_act_online_20_colegio, file = "../output/graphs/part_act_online_20_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_online_21_1s = as.numeric(data_wide$part_pol_online_info + data_wide$part_pol_online_post + data_wide$part_pol_online_com + data_wide$part_pol_online_seg)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_online_21_1s, na.rm=T),
               psych::describe(data_ed_med$part_act_online_21_1s, na.rm=T),
               psych::describe(data_ed_ter$part_act_online_21_1s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_online_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_online_21_1s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_online_21_1s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_online_21_1s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_online_21_1s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_online_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
nivel educativo de la madre") + ylim(0,4)
#part_act_online_21_1s_colegio
ggsave(part_act_online_21_1s_colegio, file = "../output/graphs/part_act_online_21_1s_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_act_online_21_2s = as.numeric(data_wide$part_pol_online_info_21b + data_wide$part_pol_online_post_21b + data_wide$part_pol_online_com_21b + data_wide$part_pol_online_seg_21b)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_online_21_2s, na.rm=T),
               psych::describe(data_ed_med$part_act_online_21_2s, na.rm=T),
               psych::describe(data_ed_ter$part_act_online_21_2s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_online_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_online_21_2s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_online_21_2s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_online_21_2s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_online_21_2s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_online_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
nivel educativo de la madre") + ylim(0,4)
#part_act_online_21_2s_colegio
ggsave(part_act_online_21_2s_colegio, file = "../output/graphs/part_act_online_21_2s_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_online_3y4 <- as.numeric(data_wide$part_pol_online + data_wide$part_online_post + data_wide$part_online_com + data_wide$part_online_seg)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_online_3y4, na.rm=T),
               psych::describe(data_ed_med$part_act_online_3y4, na.rm=T),
               psych::describe(data_ed_ter$part_act_online_3y4, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_online_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_online_3y4,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_online_3y4,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_online_3y4,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_online_3y4,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_online_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
nivel educativo de la padre") + ylim(0,4)
#part_act_online_3y4_colegio
ggsave(part_act_online_3y4_colegio, file = "../output/graphs/part_act_online_3y4_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_online_es <- as.numeric(data_wide$part_pol_online_info_21 + data_wide$part_pol_online_post_21 + data_wide$part_pol_online_com_21 + data_wide$part_pol_online_seg_21)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_online_es, na.rm=T),
               psych::describe(data_ed_med$part_act_online_es, na.rm=T),
               psych::describe(data_ed_ter$part_act_online_es, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_online_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_online_es,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_online_es,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_online_es,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_online_es,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_online_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
nivel educativo de la padre") + ylim(0,4)
#part_act_online_es_colegio
ggsave(part_act_online_es_colegio, file = "../output/graphs/part_act_online_es_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_online_20 = as.numeric(data_wide$part_pol_online_info_20 + data_wide$part_pol_online_post_20 + data_wide$part_pol_online_com_20 + data_wide$part_pol_online_seg_20   )/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_online_20, na.rm=T),
               psych::describe(data_ed_med$part_act_online_20, na.rm=T),
               psych::describe(data_ed_ter$part_act_online_20, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_online_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_online_20,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_online_20,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_online_20,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_online_20,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_online_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
nivel educativo de la padre") + ylim(0,4)
#part_act_online_20_colegio
ggsave(part_act_online_20_colegio, file = "../output/graphs/part_act_online_20_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_online_21_1s = as.numeric(data_wide$part_pol_online_info + data_wide$part_pol_online_post + data_wide$part_pol_online_com + data_wide$part_pol_online_seg)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_online_21_1s, na.rm=T),
               psych::describe(data_ed_med$part_act_online_21_1s, na.rm=T),
               psych::describe(data_ed_ter$part_act_online_21_1s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_online_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_online_21_1s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_online_21_1s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_online_21_1s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_online_21_1s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_online_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
nivel educativo de la padre") + ylim(0,4)
#part_act_online_21_1s_colegio
ggsave(part_act_online_21_1s_colegio, file = "../output/graphs/part_act_online_21_1s_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_act_online_21_2s = as.numeric(data_wide$part_pol_online_info_21b + data_wide$part_pol_online_post_21b + data_wide$part_pol_online_com_21b + data_wide$part_pol_online_seg_21b)/4
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_act_online_21_2s, na.rm=T),
               psych::describe(data_ed_med$part_act_online_21_2s, na.rm=T),
               psych::describe(data_ed_ter$part_act_online_21_2s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_act_online_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_act_online_21_2s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_act_online_21_2s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_act_online_21_2s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_act_online_21_2s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_act_online_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
nivel educativo de la padre") + ylim(0,4)
#part_act_online_21_2s_colegio
ggsave(part_act_online_21_2s_colegio, file = "../output/graphs/part_act_online_21_2s_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos

Participación política durante 3ro y 4to medio

### Crear variable
data_wide$part_act_online_3y4 <- as.numeric(data_wide$part_pol_online + data_wide$part_online_post + data_wide$part_online_com + data_wide$part_online_seg)/4
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padr_poli==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padr_poli==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padr_poli==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padr_poli==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_online_3y4, na.rm=T),
               psych::describe(data_casi_nunca$part_act_online_3y4, na.rm=T),
               psych::describe(data_a_veces$part_act_online_3y4, na.rm=T),
               psych::describe(data_frecuent$part_act_online_3y4, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_online_3y4,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_online_3y4,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_online_3y4,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_online_3y4,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_online_3y4_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_online_3y4_colegio
ggsave(part_act_online_3y4_colegio, file = "../output/graphs/part_act_online_3y4_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### Crear variable
data_wide$part_act_online_es <- as.numeric(data_wide$part_pol_online_info_21 + data_wide$part_pol_online_post_21 + data_wide$part_pol_online_com_21 + data_wide$part_pol_online_seg_21)/4
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_21==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_21==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_21==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_21==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_online_es, na.rm=T),
               psych::describe(data_casi_nunca$part_act_online_es, na.rm=T),
               psych::describe(data_a_veces$part_act_online_es, na.rm=T),
               psych::describe(data_frecuent$part_act_online_es, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_online_es,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_online_es,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_online_es,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_online_es,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_online_es_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_online_es_colegio
ggsave(part_act_online_es_colegio, file = "../output/graphs/part_act_online_es_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### Crear variable
data_wide$part_act_online_20 = as.numeric(data_wide$part_pol_online_info_20 + data_wide$part_pol_online_post_20 + data_wide$part_pol_online_com_20 + data_wide$part_pol_online_seg_20   )/4
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_20==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_20==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_20==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_20==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_online_20, na.rm=T),
               psych::describe(data_casi_nunca$part_act_online_20, na.rm=T),
               psych::describe(data_a_veces$part_act_online_20, na.rm=T),
               psych::describe(data_frecuent$part_act_online_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_online_20,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_online_20,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_online_20,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_online_20,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_online_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_online_20_colegio
ggsave(part_act_online_20_colegio, file = "../output/graphs/part_act_online_20_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_act_online_21_1s = as.numeric(data_wide$part_pol_online_info + data_wide$part_pol_online_post + data_wide$part_pol_online_com + data_wide$part_pol_online_seg)/4
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_online_21_1s, na.rm=T),
               psych::describe(data_casi_nunca$part_act_online_21_1s, na.rm=T),
               psych::describe(data_a_veces$part_act_online_21_1s, na.rm=T),
               psych::describe(data_frecuent$part_act_online_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_online_21_1s,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_online_21_1s,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_online_21_1s,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_online_21_1s,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_online_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_online_21_1s_colegio
ggsave(part_act_online_21_1s_colegio, file = "../output/graphs/part_act_online_21_1s_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### Crear variable
data_wide$part_act_online_21_2s = as.numeric(data_wide$part_pol_online_info_21b + data_wide$part_pol_online_post_21b + data_wide$part_pol_online_com_21b + data_wide$part_pol_online_seg_21b)/4
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_21b==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_21b==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_21b==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_21b==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_act_online_21_2s, na.rm=T),
               psych::describe(data_casi_nunca$part_act_online_21_2s, na.rm=T),
               psych::describe(data_a_veces$part_act_online_21_2s, na.rm=T),
               psych::describe(data_frecuent$part_act_online_21_2s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_act_online_21_2s,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_act_online_21_2s,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_act_online_21_2s,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_act_online_21_2s,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_act_online_21_2s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
online (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista online por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_act_online_21_2s_colegio
ggsave(part_act_online_21_2s_colegio, file = "../output/graphs/part_act_online_21_2s_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Activismo social o comunitario

Dependencia administrativa establecimiento

Participación política durante 3ro y 4to medio

### Variable: part_pol_volunt
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_pol_volunt, na.rm=T),
               psych::describe(data_sub$part_pol_volunt, na.rm=T),psych::describe(data_priv$part_pol_volunt, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)
pond1 <- stats::weighted.mean(x=data_mun$part_pol_volunt,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_pol_volunt,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_pol_volunt,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_pol_volunt_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_pol_volunt_colegio
ggsave(part_pol_volunt_colegio, file = "../output/graphs/part_pol_volunt_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

###  variable part_pol_com_21
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_pol_com_21, na.rm=T),
               psych::describe(data_sub$part_pol_com_21, na.rm=T),psych::describe(data_priv$part_pol_com_21, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_pol_com_21,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_pol_com_21,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_pol_com_21,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_pol_com_21_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_pol_com_21_colegio
ggsave(part_pol_com_21_colegio, file = "../output/graphs/part_pol_com_21_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### variable part_pol_com_20
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_pol_com_20, na.rm=T),
               psych::describe(data_sub$part_pol_com_20, na.rm=T),psych::describe(data_priv$part_pol_com_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_pol_com_20,y=data_mun$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_pol_com_20,y=data_sub$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_pol_com_20,y=data_priv$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_pol_com_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
          ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') +  
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_pol_com_20_colegio
ggsave(part_pol_com_20_colegio, file = "../output/graphs/part_pol_com_20_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### variable part_pol_com
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_pol_com, na.rm=T),
               psych::describe(data_sub$part_pol_com, na.rm=T),psych::describe(data_priv$part_pol_com, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_pol_com,y=data_mun$weight_w02,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_pol_com,y=data_sub$weight_w02,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_pol_com,y=data_priv$weight_w02,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_pol_com_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_pol_com_colegio
ggsave(part_pol_com_colegio, file = "../output/graphs/part_pol_com_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### variable part_pol_com_21b
# Creación de bbdd
data_mun = data_wide %>%  filter(edm_admi==1) %>% as.data.frame() #Municipal
data_sub = data_wide %>%  filter(edm_admi==2) %>% as.data.frame() #Particular Subvencionado
data_priv = data_wide %>%  filter(edm_admi==3) %>% as.data.frame() #Particular pagado
table_preposh1<- rbind(psych::describe(data_mun$part_pol_com_21b, na.rm=T),
               psych::describe(data_sub$part_pol_com_21b, na.rm=T),psych::describe(data_priv$part_pol_com_21b, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_mun$part_pol_com_21b,y=data_mun$weight_w03,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_sub$part_pol_com_21b,y=data_sub$weight_w03,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_priv$part_pol_com_21b,y=data_priv$weight_w03,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3

table_preposh1$dep <- c("Municipal","Particular Subvencionado","Particular Privado")

part_pol_com_21b_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
     theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
tipo de dependencia administrativa de la escuela") + ylim(0,4)
#part_pol_com_21b_colegio
ggsave(part_pol_com_21b_colegio, file = "../output/graphs/part_pol_com_21b_colegio_dep.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

Participación política durante 3ro y 4to medio

### Variable: part_pol_volunt
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_volunt, na.rm=T),
               psych::describe(data_ed_med$part_pol_volunt, na.rm=T),
               psych::describe(data_ed_ter$part_pol_volunt, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_volunt, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_volunt,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_volunt,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_volunt,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_volunt,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_volunt_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
nivel educativo de la madre") + ylim(0,4)
#part_pol_volunt_colegio
ggsave(part_pol_volunt_colegio, file = "../output/graphs/part_pol_volunt_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### variable part_pol_com_21
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_com_21, na.rm=T),
               psych::describe(data_ed_med$part_pol_com_21, na.rm=T),
               psych::describe(data_ed_ter$part_pol_com_21, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_com_21, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_com_21,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_com_21,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_com_21,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_com_21,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_com_21_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
nivel educativo de la madre") + ylim(0,4)
#part_pol_com_21_colegio
ggsave(part_pol_com_21_colegio, file = "../output/graphs/part_pol_com_21_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### variable part_pol_com_20
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_com_20, na.rm=T),
               psych::describe(data_ed_med$part_pol_com_20, na.rm=T),
               psych::describe(data_ed_ter$part_pol_com_20, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_com_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_com_20,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_com_20,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_com_20,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_com_20,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_com_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
nivel educativo de la madre") + ylim(0,4)
#part_pol_com_20_colegio
ggsave(part_pol_com_20_colegio, file = "../output/graphs/part_pol_com_20_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### Crear variable
data_wide$part_pol_com_21_1s = as.numeric(data_wide$part_pol_firma.x + data_wide$part_pol_marc_pac)/2
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_com_21_1s, na.rm=T),
               psych::describe(data_ed_med$part_pol_com_21_1s, na.rm=T),
               psych::describe(data_ed_ter$part_pol_com_21_1s, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_com_21_1s, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_com_21_1s,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_com_21_1s,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_com_21_1s,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_com_21_1s,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_com_21_1s_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
nivel educativo de la madre") + ylim(0,4)
#part_pol_com_21_1s_colegio
ggsave(part_pol_com_21_1s_colegio, file = "../output/graphs/part_pol_com_21_1s_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### variable part_pol_com_21b
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_madre==1 | nse_madre==2 | nse_madre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_madre==4 | nse_madre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_madre==6 | nse_madre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_madre==8 | nse_madre==9 | nse_madre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_com_21b, na.rm=T),
               psych::describe(data_ed_med$part_pol_com_21b, na.rm=T),
               psych::describe(data_ed_ter$part_pol_com_21b, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_com_21b, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_com_21b,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_com_21b,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_com_21b,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_com_21b,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_com_21b_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
nivel educativo de la madre") + ylim(0,4)
#part_pol_com_21b_colegio
ggsave(part_pol_com_21b_colegio, file = "../output/graphs/part_pol_com_21b_colegio_ed_madre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

Participación política durante 3ro y 4to medio

### Variable: part_pol_volunt
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_volunt, na.rm=T),
               psych::describe(data_ed_med$part_pol_volunt, na.rm=T),
               psych::describe(data_ed_ter$part_pol_volunt, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_volunt, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_volunt,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_volunt,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_volunt,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_volunt,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_volunt_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
nivel educativo de la padre") + ylim(0,4)
#part_pol_volunt_colegio
ggsave(part_pol_volunt_colegio, file = "../output/graphs/part_pol_volunt_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### variable part_pol_com_21
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_com_21, na.rm=T),
               psych::describe(data_ed_med$part_pol_com_21, na.rm=T),
               psych::describe(data_ed_ter$part_pol_com_21, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_com_21, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_com_21,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_com_21,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_com_21,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_com_21,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_com_21_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
nivel educativo de la padre") + ylim(0,4)
#part_pol_com_21_colegio
ggsave(part_pol_com_21_colegio, file = "../output/graphs/part_pol_com_21_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### variable part_pol_com_20
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_com_20, na.rm=T),
               psych::describe(data_ed_med$part_pol_com_20, na.rm=T),
               psych::describe(data_ed_ter$part_pol_com_20, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_com_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_com_20,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_com_20,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_com_20,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_com_20,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_com_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
nivel educativo de la padre") + ylim(0,4)
#part_pol_com_20_colegio
ggsave(part_pol_com_20_colegio, file = "../output/graphs/part_pol_com_20_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### variable part_pol_com
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_com, na.rm=T),
               psych::describe(data_ed_med$part_pol_com, na.rm=T),
               psych::describe(data_ed_ter$part_pol_com, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_com, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_com,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_com,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_com,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_com,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_com_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
nivel educativo de la padre") + ylim(0,4)
#part_pol_com_colegio
ggsave(part_pol_com_colegio, file = "../output/graphs/part_pol_com_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### variable part_pol_com_21b
# Creación de bbdd
data_ed_bas = data_wide %>%  filter(nse_padre==1 | nse_padre==2 | nse_padre==3) %>% as.data.frame() # Sin Ed. (1), Ed. básica incompleta (2) o completa (3)
data_ed_med = data_wide %>%  filter(nse_padre==4 | nse_padre==5) %>% as.data.frame() # Ed. media incompleta (4) o completa (5)
data_ed_ter = data_wide %>%  filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # técnico superior incompleto (6) o completo (7) Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)

#data_ed_tec = data_wide %>%  filter(nse_padre==6 | nse_padre==7) %>% as.data.frame() # técnico superior incompleto (6) o completo (7)
#data_ed_uni = data_wide %>%  filter(nse_padre==8 | nse_padre==9 | nse_padre==10) %>% as.data.frame() # Universitaria incompleta (8) o completa (9), Estudios de postgrado (magíster o doctorado) (10)
table_preposh1<- rbind(psych::describe(data_ed_bas$part_pol_com_21b, na.rm=T),
               psych::describe(data_ed_med$part_pol_com_21b, na.rm=T),
               psych::describe(data_ed_ter$part_pol_com_21b, na.rm=T))#,
#               psych::describe(data_ed_uni$part_pol_com_21b, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_ed_bas$part_pol_com_21b,y=data_ed_bas$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_ed_med$part_pol_com_21b,y=data_ed_med$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_ed_ter$part_pol_com_21b,y=data_ed_ter$weight_w01,na.rm=TRUE)
#pond4 <- stats::weighted.mean(x=data_ed_uni$part_pol_com_21b,y=data_ed_uni$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
#table_preposh1[4,2]<-pond4

#table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Técnico superior", "Universitaria o más")
table_preposh1$dep <- c("Ed. básica o menos","Ed. media","Ed. terciaria")

part_pol_com_21b_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
nivel educativo de la padre") + ylim(0,4)
#part_pol_com_21b_colegio
ggsave(part_pol_com_21b_colegio, file = "../output/graphs/part_pol_com_21b_colegio_ed_padre.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos

Participación política durante 3ro y 4to medio

### Variable: part_pol_volunt
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padr_poli==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padr_poli==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padr_poli==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padr_poli==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_pol_volunt, na.rm=T),
               psych::describe(data_casi_nunca$part_pol_volunt, na.rm=T),
               psych::describe(data_a_veces$part_pol_volunt, na.rm=T),
               psych::describe(data_frecuent$part_pol_volunt, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_pol_volunt,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_pol_volunt,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_pol_volunt,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_pol_volunt,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_pol_volunt_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_pol_volunt_colegio
ggsave(part_pol_volunt_colegio, file = "../output/graphs/part_pol_volunt_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante estallido social

### variable part_pol_com_21
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_21==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_21==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_21==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_21==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_pol_com_21, na.rm=T),
               psych::describe(data_casi_nunca$part_pol_com_21, na.rm=T),
               psych::describe(data_a_veces$part_pol_com_21, na.rm=T),
               psych::describe(data_frecuent$part_pol_com_21, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_pol_com_21,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_pol_com_21,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_pol_com_21,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_pol_com_21,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_pol_com_21_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_pol_com_21_colegio
ggsave(part_pol_com_21_colegio, file = "../output/graphs/part_pol_com_21_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el 2020

### variable part_pol_com_20
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_20==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_20==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_20==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_20==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_pol_com_20, na.rm=T),
               psych::describe(data_casi_nunca$part_pol_com_20, na.rm=T),
               psych::describe(data_a_veces$part_pol_com_20, na.rm=T),
               psych::describe(data_frecuent$part_pol_com_20, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_pol_com_20,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_pol_com_20,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_pol_com_20,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_pol_com_20,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_pol_com_20_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_pol_com_20_colegio
ggsave(part_pol_com_20_colegio, file = "../output/graphs/part_pol_com_20_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el primer semestre de 2021

#### variable part_pol_com
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_pol_com, na.rm=T),
               psych::describe(data_casi_nunca$part_pol_com, na.rm=T),
               psych::describe(data_a_veces$part_pol_com, na.rm=T),
               psych::describe(data_frecuent$part_pol_com, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_pol_com,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_pol_com,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_pol_com,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_pol_com,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_pol_com_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_pol_com_colegio
ggsave(part_pol_com_colegio, file = "../output/graphs/part_pol_com_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Participación política durante el segundo semestre de 2021

#### variable part_pol_com_21b
# Creación de bbdd
data_nunca = data_wide %>%  filter(conv_padres_21b==1) %>% as.data.frame() # Nunca
data_casi_nunca = data_wide %>%  filter(conv_padres_21b==2) %>% as.data.frame() # Casi nunca
data_a_veces = data_wide %>%  filter(conv_padres_21b==3) %>% as.data.frame() # A veces
data_frecuent = data_wide %>%  filter(conv_padres_21b==4) %>% as.data.frame() # Frecuentemente
table_preposh1<- rbind(psych::describe(data_nunca$part_pol_com_21b, na.rm=T),
               psych::describe(data_casi_nunca$part_pol_com_21b, na.rm=T),
               psych::describe(data_a_veces$part_pol_com_21b, na.rm=T),
               psych::describe(data_frecuent$part_pol_com_21b, na.rm=T))
table_preposh1 <- table_preposh1 %>% select(n,mean,sd,median,trimmed,min,max)

pond1 <- stats::weighted.mean(x=data_nunca$part_pol_com_21b,y=data_nunca$weight_w01,na.rm=TRUE)
pond2 <- stats::weighted.mean(x=data_casi_nunca$part_pol_com_21b,y=data_casi_nunca$weight_w01,na.rm=TRUE)
pond3 <- stats::weighted.mean(x=data_a_veces$part_pol_com_21b,y=data_a_veces$weight_w01,na.rm=TRUE)
pond4 <- stats::weighted.mean(x=data_frecuent$part_pol_com_21b,y=data_frecuent$weight_w01,na.rm=TRUE)

table_preposh1[1,2]<-pond1
table_preposh1[2,2]<-pond2
table_preposh1[3,2]<-pond3
table_preposh1[4,2]<-pond4

table_preposh1$dep <- c("1. Nunca","2. Casi nunca","3. A veces", "4. Frecuentemente")

part_pol_com_21b_colegio <-  ggplot(data=table_preposh1, aes(x=dep, y=mean, fill=dep)) +
     geom_bar(position = 'dodge', stat='identity')+#,width=0.8) 
     scale_fill_brewer(palette="Purples") +
     geom_text(aes(label=format(round(mean,2)), y=0), position=position_dodge(0.9), hjust=-0.25, size=6) +
     theme_bw(base_size = 14) +
     scale_y_continuous(labels = scales::comma) +
     ylab('Puntaje promedio en participación activista 
social o comunitaria (escala de 1 a 4)') + xlab(' ') + 
  theme(legend.position="top") +
     labs(fill = " ") +
    coord_flip()+
    theme(axis.text.x = element_text(colour = "grey20", size = 14, angle = 360, hjust = 0.5, vjust = 0.5, face = "bold"),
          axis.text.y = element_text(colour = "grey20", size = 14), 
          text = element_text(size = 14, face = "bold"),
          plot.title = element_text(hjust=0.5),
          legend.position = "none") + 
     ggtitle("Participación activista social o comunitaria por 
conversación con los padres sobre temas políticos y/o sociales") + ylim(0,4)
#part_pol_com_21b_colegio
ggsave(part_pol_com_21b_colegio, file = "../output/graphs/part_pol_com_21b_colegio_conv_padres.png",device = "png",width = 23,height = 13,dpi = "retina",units = "cm")

Elecciones presidenciales 2017

Dependencia administrativa establecimiento

### variable voto_pres_17
bbdd_general0 <- data_wide  %>% dplyr::select(voto_pres_17)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_pres_17,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_pres_17,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_pres_17,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))

ggsave(elec_17_dep, file = "../output/graphs/elec_17_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pres_17
bbdd_dep <- data_wide  %>% dplyr::select(voto_pres_17) %>% filter(voto_pres_17!=2)
bbdd_dep <- na.omit(bbdd_dep)
bbdd_general =
  bbdd_dep %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pres_17!=2)
bbdd_mun0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_17_dep, file = "../output/graphs/elec_17_dep_0y1.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_pres_17
bbdd_general0 <- data_wide  %>% dplyr::select(voto_pres_17)
bbdd_general0 <- na.omit(bbdd_general0)

bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_pres_17,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3) 
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_pres_17,nse_madre) %>% filter(nse_madre==4 | nse_madre==5) 
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_pres_17,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) 
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_17_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))

ggsave(elec_17_edmad, file = "../output/graphs/elec_17_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pres_17

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pres_17) %>% filter(voto_pres_17!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pres_17!=2)
bbdd_ed_bas0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3) 
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,nse_madre) %>% filter(nse_madre==4 | nse_madre==5) 
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10) 
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_17_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_17_edmad, file = "../output/graphs/elec_17_edmad_0y1.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_pres_17

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pres_17)
bbdd_general0 <- na.omit(bbdd_general0)

bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_pres_17,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3) 
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_pres_17,nse_padre) %>% filter(nse_padre==4 | nse_padre==5) 
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_pres_17,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) 
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_17_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))

ggsave(elec_17_edpad, file = "../output/graphs/elec_17_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pres_17

bbdd_edpad0 <- data_wide  %>% dplyr::select(voto_pres_17) %>% filter(voto_pres_17!=2)
bbdd_edpad0 <- na.omit(bbdd_edpad0)
bbdd_general =
  bbdd_edpad0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pres_17!=2)
bbdd_ed_bas0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3) 
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,nse_padre) %>% filter(nse_padre==4 | nse_padre==5) 
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10) 
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_17_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_17_edpad, file = "../output/graphs/elec_17_edpad_0y1.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_pres_17

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pres_17)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_pres_17,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_pres_17,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_pres_17,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_pres_17,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  data_wide %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_17_conv_pad_3y4, file = "../output/graphs/elec_17_conv_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pres_17

bbdd_general0 <- data_wide %>% dplyr::select(voto_pres_17) %>% filter(voto_pres_17!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide  %>% filter(voto_pres_17!=2)

bbdd_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_17_conv_pad_3y4, file = "../output/graphs/elec_17_conv_pad_3y4_0y1.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_pres_17

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pres_17)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_pres_17,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_pres_17,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_pres_17,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_pres_17,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  data_wide %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_17_conv_pad_3y4, file = "../output/graphs/elec_17_conv_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pres_17

bbdd_general0 <- data_wide %>% dplyr::select(voto_pres_17) %>% filter(voto_pres_17!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide  %>% filter(voto_pres_17!=2)

bbdd_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_elect_pres17  %>% dplyr::select(voto_pres_17,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_17_conv_pad_3y4, file = "../output/graphs/elec_17_conv_pad_est_19_0y1.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_pres_17

bbdd_general0 <- data_wide %>% dplyr::select(voto_pres_17)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_17_conv_pad_3y4, file = "../output/graphs/elec_17_conv_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pres_17

bbdd_general0 <- data_wide %>% dplyr::select(voto_pres_17)  %>% filter(voto_pres_17!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide  %>% filter(voto_pres_17!=2)

bbdd_nunca0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_17_conv_pad_3y4, file = "../output/graphs/elec_17_conv_pad_20_0y1.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_pres_17

bbdd_general0 <- data_wide %>% dplyr::select(voto_pres_17)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca0 =
  bbdd_casi_nunca0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres) %>% filter(conv_padres==4)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_17_conv_pad_3y4, file = "../output/graphs/elec_17_conv_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pres_17

bbdd_general0 <- data_wide %>% dplyr::select(voto_pres_17) %>% filter(voto_pres_17!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide  %>% filter(voto_pres_17!=2)

bbdd_nunca0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca0 =
  bbdd_casi_nunca0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_17_conv_pad_3y4, file = "../output/graphs/elec_17_conv_pad_21a_0y1.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_pres_17

bbdd_general0 <- data_wide %>% dplyr::select(voto_pres_17)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide %>% dplyr::select(voto_pres_17,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_17_conv_pad_3y4, file = "../output/graphs/elec_17_conv_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pres_17

bbdd_general0 <- data_wide %>% dplyr::select(voto_pres_17) %>% filter(voto_pres_17!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pres_17) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide  %>% filter(voto_pres_17!=2)

bbdd_nunca0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>%
              group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_elect_pres17 %>% dplyr::select(voto_pres_17,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% group_by(voto_pres_17) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_17_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pres_17))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_17_conv_pad_3y4, file = "../output/graphs/elec_17_conv_pad_21b_0y1.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Elecciones plebiscito constitucional 2020

Dependencia administrativa establecimiento

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb  ) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_pleb,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>%
              group_by(voto_pleb    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_pleb,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% group_by(voto_pleb  ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_pleb,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% group_by(voto_pleb ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_20_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb   ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))

ggsave(elec_20_dep, file = "../output/graphs/elec_pleb_20_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

#### sin categoría “no tenía edad”

### variable voto_pleb
bbdd_dep <- data_wide  %>% dplyr::select(voto_pleb) %>% filter(voto_pleb!=2)
bbdd_dep <- na.omit(bbdd_dep)
bbdd_general =
  bbdd_dep %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pleb!=2)

bbdd_mun0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_20_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_pleb_20_dep, file = "../output/graphs/elec_pleb_20_dep_0y1.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_pleb  

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb  ) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_pleb,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_pleb    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_pleb,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>% group_by(voto_pleb   ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_pleb,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>%
              group_by(voto_pleb    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_20_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))

ggsave(elec_20_edmad, file = "../output/graphs/elec_pleb_20_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

#### sin categoría “no tenía edad”

### variable voto_pleb
bbdd_dep <- data_wide  %>% dplyr::select(voto_pleb) %>% filter(voto_pleb!=2)
bbdd_dep <- na.omit(bbdd_dep)
bbdd_general =
  bbdd_dep %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pleb!=2)

bbdd_ed_bas0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_pleb    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>% group_by(voto_pleb   ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>%
              group_by(voto_pleb    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_20_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_20_edmad, file = "../output/graphs/elec_pleb_20_edmad_0y1.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_pleb  


bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb  ) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_pleb,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_pleb    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_pleb,nse_padre) %>% filter(nse_padre==4 | nse_padre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>% group_by(voto_pleb   ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_pleb,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>%
              group_by(voto_pleb    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))
bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_20_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))

ggsave(elec_20_edpad, file = "../output/graphs/elec_pleb_20_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pleb
bbdd_dep <- data_wide  %>% dplyr::select(voto_pleb) %>% filter(voto_pleb!=2)
bbdd_dep <- na.omit(bbdd_dep)
bbdd_general =
  bbdd_dep %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pleb!=2)

bbdd_ed_bas0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_pleb    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>% group_by(voto_pleb   ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>%
              group_by(voto_pleb    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_20_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_20_edmad, file = "../output/graphs/elec_pleb_20_edmad_0y1.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_pleb_conv_pad_3y4, file = "../output/graphs/elec_pleb_conv_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb) %>% filter(voto_pleb!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pleb!=2)

bbdd_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_pleb_conv_pad_3y4, file = "../output/graphs/elec_pleb_conv_pad_3y4_0y1.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==1) 
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>%
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==2) 
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==3) 
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==4) 
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_pleb_conv_pad_3y4, file = "../output/graphs/elec_pleb_conv_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb) %>% filter(voto_pleb!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pleb!=2)

bbdd_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_pleb_conv_pad_3y4, file = "../output/graphs/elec_pleb_conv_pad_est_19_0y1.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>%
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_pleb_conv_pad_3y4, file = "../output/graphs/elec_pleb_conv_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb) %>% filter(voto_pleb!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pleb!=2)

bbdd_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_pleb_conv_pad_3y4, file = "../output/graphs/elec_pleb_conv_pad_20_0y1.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))


bbdd_nunca0 <- data_wide %>% dplyr::select(voto_pleb,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide %>% dplyr::select(voto_pleb,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_pleb_conv_pad_3y4, file = "../output/graphs/elec_pleb_conv_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb) %>% filter(voto_pleb!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pleb!=2)

bbdd_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_pleb_conv_pad_3y4, file = "../output/graphs/elec_pleb_conv_pad_21a_0y1.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>%
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_pleb,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_pleb_conv_pad_3y4, file = "../output/graphs/elec_pleb_conv_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

sin categoría “no tenía edad”

### variable voto_pleb

bbdd_general0 <- data_wide  %>% dplyr::select(voto_pleb) %>% filter(voto_pleb!=2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_pleb) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

## creación bbdd para análisis excluyendo categoría "No tenía edad"
data_elect_pres17 <- data_wide %>% filter(voto_pleb!=2)

bbdd_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_elect_pres17  %>% dplyr::select(voto_pleb,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_pleb) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_pleb_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_pleb))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_pleb_conv_pad_3y4, file = "../output/graphs/elec_pleb_conv_pad_21b_0y1.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Elecciones diputados 2021

Dependencia administrativa establecimiento

### variable voto_dipu

bbdd_general0 <- data_wide  %>% dplyr::select(voto_dipu)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_dipu) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_dipu,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_dipu,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>%
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_dipu,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_dipu_21_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_dipu))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_dipu_21_dep, file = "../output/graphs/elec_dipu_21_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_dipu

bbdd_general0 <- data_wide  %>% dplyr::select(voto_dipu)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_dipu) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_dipu,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_dipu    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_dipu,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>% group_by(voto_dipu   ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_dipu,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>%
              group_by(voto_dipu    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_dipu_21_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_dipu))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_dipu_21_edmad, file = "../output/graphs/elec_dipu_21_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_dipu

bbdd_general0 <- data_wide  %>% dplyr::select(voto_dipu)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_dipu) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_dipu,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_dipu    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_dipu,nse_padre) %>% filter(nse_padre==4 | nse_padre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>% group_by(voto_dipu   ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_dipu,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>%
              group_by(voto_dipu    ) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_dipu_21_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_dipu))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_dipu_21_edpad, file = "../output/graphs/elec_dipu_21_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_dipu

bbdd_general0 <- data_wide  %>% dplyr::select(voto_dipu)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_dipu) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_dipu_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_dipu))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_dipu_21_conv_pad_3y4, file = "../output/graphs/elec_dipu_21_conv_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_dipu


bbdd_general0 <- data_wide  %>% dplyr::select(voto_dipu)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_dipu) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_dipu_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_dipu))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_dipu_21_conv_pad_3y4, file = "../output/graphs/elec_dipu_21_conv_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_dipu


bbdd_general0 <- data_wide  %>% dplyr::select(voto_dipu)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_dipu) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_dipu,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_dipu_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_dipu))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_dipu_21_conv_pad_3y4, file = "../output/graphs/elec_dipu_21_conv_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_dipu


bbdd_general0 <- data_wide  %>% dplyr::select(voto_dipu)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_dipu) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_dipu, conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>%
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_dipu, conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_dipu, conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_dipu, conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_dipu_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_dipu))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_dipu_21_conv_pad_3y4, file = "../output/graphs/elec_dipu_21_conv_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_dipu

bbdd_general0 <- data_wide  %>% dplyr::select(voto_dipu)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_dipu) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_dipu, conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_dipu, conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_dipu, conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces0 =
  bbdd_a_veces0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_dipu, conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>% 
              group_by(voto_dipu) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_dipu_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_dipu))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_dipu_21_conv_pad_3y4, file = "../output/graphs/elec_dipu_21_conv_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Elecciones primera vuelta 2021

Dependencia administrativa establecimiento

### variable voto_privuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_privuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_privuelta) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_privuelta,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_privuelta,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_privuelta,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_privuelta_21_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_privuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_privuelta_21_dep, file = "../output/graphs/elec_privuelta_21_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_privuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_privuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_privuelta) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_privuelta,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_privuelta,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_privuelta,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_privuelta_21_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_privuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_privuelta_21_edmad, file = "../output/graphs/elec_privuelta_21_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_privuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_privuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_privuelta) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_privuelta,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_privuelta,nse_padre) %>% filter(nse_padre==4 | nse_padre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_privuelta,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_privuelta_21_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_privuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_privuelta_21_edpad, file = "../output/graphs/elec_privuelta_21_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_privuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_privuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_privuelta) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_privuelta_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_privuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_privuelta_21_conv_pad_3y4, file = "../output/graphs/elec_privuelta_21_conv_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_privuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_privuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_privuelta) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_privuelta_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_privuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_privuelta_21_conv_pad_3y4, file = "../output/graphs/elec_privuelta_21_conv_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_privuelta
### conv_padres_20

bbdd_general0 <- data_wide  %>% dplyr::select(voto_privuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_privuelta) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_privuelta_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_privuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_privuelta_21_conv_pad_3y4, file = "../output/graphs/elec_privuelta_21_conv_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_privuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_privuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_privuelta) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_privuelta_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_privuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_privuelta_21_conv_pad_3y4, file = "../output/graphs/elec_privuelta_21_conv_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_privuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_privuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_privuelta) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_privuelta,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_privuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_privuelta_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_privuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_privuelta_21_conv_pad_3y4, file = "../output/graphs/elec_privuelta_21_conv_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Elecciones segunda vuelta 2021

Dependencia administrativa establecimiento

### variable voto_segvuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_segvuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_segvuelta) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_segvuelta,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_segvuelta,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_segvuelta,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_segvuelta_21_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_segvuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_segvuelta_21_dep, file = "../output/graphs/elec_segvuelta_21_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_segvuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_segvuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_segvuelta) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_segvuelta,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_segvuelta,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_segvuelta,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_segvuelta_21_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_segvuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_segvuelta_21_edmad, file = "../output/graphs/elec_segvuelta_21_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_segvuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_segvuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_segvuelta) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_segvuelta,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_segvuelta,nse_padre) %>% filter(nse_padre==4 | nse_padre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_segvuelta,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_segvuelta_21_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_segvuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_segvuelta_21_edpad, file = "../output/graphs/elec_segvuelta_21_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_segvuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_segvuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_segvuelta) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_segvuelta_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_segvuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_segvuelta_21_conv_pad_3y4, file = "../output/graphs/elec_segvuelta_21_conv_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_segvuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_segvuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_segvuelta) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_segvuelta_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_segvuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_segvuelta_21_conv_pad_3y4, file = "../output/graphs/elec_segvuelta_21_conv_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_segvuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_segvuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_segvuelta) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_segvuelta_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_segvuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_segvuelta_21_conv_pad_3y4, file = "../output/graphs/elec_segvuelta_21_conv_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_segvuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_segvuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_segvuelta) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_segvuelta_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_segvuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_segvuelta_21_conv_pad_3y4, file = "../output/graphs/elec_segvuelta_21_conv_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_segvuelta

bbdd_general0 <- data_wide  %>% dplyr::select(voto_segvuelta)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_segvuelta) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_segvuelta,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_segvuelta) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_segvuelta_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_segvuelta))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_segvuelta_21_conv_pad_3y4, file = "../output/graphs/elec_segvuelta_21_conv_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Elecciones organo constituyente 2021

Dependencia administrativa establecimiento

### variable voto_conv2

bbdd_general0 <- data_wide  %>% dplyr::select(voto_conv2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_conv2) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_conv2,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_conv2,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_conv2,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_org_const_21_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_conv2))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_org_const_21_dep, file = "../output/graphs/elec_org_const_21_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_conv2

bbdd_general0 <- data_wide  %>% dplyr::select(voto_conv2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_conv2) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_conv2,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_conv2,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_conv2,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_org_const_21_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_conv2))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_org_const_21_edmad, file = "../output/graphs/elec_org_const_21_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_conv2

bbdd_general0 <- data_wide  %>% dplyr::select(voto_conv2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_conv2) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_conv2,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_conv2,nse_padre) %>% filter(nse_padre==4 | nse_padre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_conv2,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_org_const_21_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_conv2))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_org_const_21_edpad, file = "../output/graphs/elec_org_const_21_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_conv2

bbdd_general0 <- data_wide  %>% dplyr::select(voto_conv2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_conv2) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_org_const_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_conv2))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_org_const_21_conv_pad_3y4, file = "../output/graphs/elec_org_const_21_conv_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_conv2

bbdd_general0 <- data_wide  %>% dplyr::select(voto_conv2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_conv2) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_org_const_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_conv2))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_org_const_21_conv_pad_3y4, file = "../output/graphs/elec_org_const_21_conv_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_conv2

bbdd_general0 <- data_wide  %>% dplyr::select(voto_conv2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_conv2) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_org_const_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_conv2))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_org_const_21_conv_pad_3y4, file = "../output/graphs/elec_org_const_21_conv_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_conv2

bbdd_general0 <- data_wide  %>% dplyr::select(voto_conv2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_conv2) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))


bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_org_const_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_conv2))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_org_const_21_conv_pad_3y4, file = "../output/graphs/elec_org_const_21_conv_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_conv2

bbdd_general0 <- data_wide  %>% dplyr::select(voto_conv2)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_conv2) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_conv2,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_conv2) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_org_const_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_conv2))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_org_const_21_conv_pad_3y4, file = "../output/graphs/elec_org_const_21_conv_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Elecciones alcaldes y concejales 2021

Dependencia administrativa establecimiento

### variable voto_muni

bbdd_general0 <- data_wide  %>% dplyr::select(voto_muni)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_muni) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_muni,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_muni,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_muni,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_muni_21_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_muni))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_muni_21_dep, file = "../output/graphs/elec_muni_21_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_muni

bbdd_general0 <- data_wide  %>% dplyr::select(voto_muni)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_muni) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_muni,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_muni,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_muni,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_muni_21_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_muni))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_muni_21_edmad, file = "../output/graphs/elec_muni_21_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_muni

bbdd_general0 <- data_wide  %>% dplyr::select(voto_muni)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_muni) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_muni,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_muni,nse_padre) %>% filter(nse_padre==4 | nse_padre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_muni,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_muni_21_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_muni))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_muni_21_edpad, file = "../output/graphs/elec_muni_21_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_muni

bbdd_general0 <- data_wide  %>% dplyr::select(voto_muni)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_muni) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_muni,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_muni,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_muni,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_muni,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_muni_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_muni))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_muni_21_conv_pad_3y4, file = "../output/graphs/elec_muni_21_conv_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_muni

bbdd_general0 <- data_wide  %>% dplyr::select(voto_muni)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_muni) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_muni_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_muni))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_muni_21_conv_pad_3y4, file = "../output/graphs/elec_muni_21_conv_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_muni

bbdd_general0 <- data_wide  %>% dplyr::select(voto_muni)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_muni) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_muni_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_muni))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_muni_21_conv_pad_3y4, file = "../output/graphs/elec_muni_21_conv_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_muni

bbdd_general0 <- data_wide  %>% dplyr::select(voto_muni)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_muni) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_muni_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_muni))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_muni_21_conv_pad_3y4, file = "../output/graphs/elec_muni_21_conv_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_muni

bbdd_general0 <- data_wide  %>% dplyr::select(voto_muni)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_muni) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_muni,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_muni) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_muni_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_muni))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_muni_21_conv_pad_3y4, file = "../output/graphs/elec_muni_21_conv_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Elecciones gobernadores 2021

Dependencia administrativa establecimiento

### variable voto_gob

bbdd_general0 <- data_wide  %>% dplyr::select(voto_gob)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_gob) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_gob,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_gob,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_gob,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_gob_21_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_gob))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_gob_21_dep, file = "../output/graphs/elec_gob_21_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_gob

bbdd_general0 <- data_wide  %>% dplyr::select(voto_gob)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_gob) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_gob,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_gob,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_gob,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_gob_21_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_gob))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_gob_21_edmad, file = "../output/graphs/elec_gob_21_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_gob

bbdd_general0 <- data_wide  %>% dplyr::select(voto_gob)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_gob) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_gob,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_gob,nse_padre) %>% filter(nse_padre==4 | nse_padre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_gob,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_gob_21_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_gob))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))

ggsave(elec_gob_21_edpad, file = "../output/graphs/elec_gob_21_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_gob

bbdd_general0 <- data_wide  %>% dplyr::select(voto_gob)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_gob) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_gob,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_gob,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_gob,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_gob,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_gob_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_gob))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_gob_21_conv_pad_3y4, file = "../output/graphs/elec_gob_21_conv_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_gob

bbdd_general0 <- data_wide  %>% dplyr::select(voto_gob)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_gob) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_gob_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_gob))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_gob_21_conv_pad_3y4, file = "../output/graphs/elec_gob_21_conv_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_gob

bbdd_general0 <- data_wide  %>% dplyr::select(voto_gob)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_gob) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_gob_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_gob))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_gob_21_conv_pad_3y4, file = "../output/graphs/elec_gob_21_conv_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_gob

bbdd_general0 <- data_wide  %>% dplyr::select(voto_gob)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_gob) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_gob_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_gob))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_gob_21_conv_pad_3y4, file = "../output/graphs/elec_gob_21_conv_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_gob

bbdd_general0 <- data_wide  %>% dplyr::select(voto_gob)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_gob) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_gob,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_gob) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_gob_21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_gob))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí"))
  
ggsave(elec_gob_21_conv_pad_3y4, file = "../output/graphs/elec_gob_21_conv_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Intención de voto en las elecciones presidenciales de 2021 (primera medición)

Dependencia administrativa establecimiento

### variable voto_fut.y

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.y)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.y) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_fut.y,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_fut.y,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_fut.y,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int1_pres21_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.y ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))

ggsave(elec_int1_pres21_dep, file = "../output/graphs/elec_int1_pres21_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_fut.y 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.y)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.y) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_fut.y,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_fut.y,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_fut.y,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_int1_pres21_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.y   ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))

ggsave(elec_int1_pres21_edmad, file = "../output/graphs/elec_int1_pres21_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_fut.y 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.y)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.y) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_fut.y,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_fut.y,nse_padre) %>% filter(nse_padre==4 | nse_padre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_fut.y,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_int1_pres21_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.y   ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))

ggsave(elec_int1_pres21_edpad, file = "../output/graphs/elec_int1_pres21_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_fut.y

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.y)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.y) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int1_pres21_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.y))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))
  
ggsave(elec_int1_pres21_pad_3y4, file = "../output/graphs/elec_int1_pres21_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_fut.y

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.y)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.y) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int1_pres21_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.y))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))
  
ggsave(elec_int1_pres21_pad_3y4, file = "../output/graphs/elec_int1_pres21_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_fut.y

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.y)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.y) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int1_pres21_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.y))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))
  
ggsave(elec_int1_pres21_pad_3y4, file = "../output/graphs/elec_int1_pres21_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_fut.y

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.y)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.y) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))


bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int1_pres21_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.y))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))
  
ggsave(elec_int1_pres21_pad_3y4, file = "../output/graphs/elec_int1_pres21_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_fut.y

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.y)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.y) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_fut.y,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_fut.y) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int1_pres21_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.y))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))
  
ggsave(elec_int1_pres21_pad_3y4, file = "../output/graphs/elec_int1_pres21_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Intención de voto en las elecciones presidenciales de 2021 (segunda medición)

Dependencia administrativa establecimiento

### variable voto_fut.x

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.x)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.x) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_fut.x,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_fut.x,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_fut.x,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int2_pres21_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.x ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))

ggsave(elec_int2_pres21_dep, file = "../output/graphs/elec_int2_pres21_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_fut.x 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.x)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.x) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_fut.x,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_fut.x,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_fut.x,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_int2_pres21_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.x   ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))

ggsave(elec_int2_pres21_edmad, file = "../output/graphs/elec_int2_pres21_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_fut.x 


bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.x)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.x) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_fut.x,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_fut.x,nse_padre) %>% filter(nse_padre==4 | nse_padre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_fut.x,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_int2_pres21_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.x   ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))

ggsave(elec_int2_pres21_edpad, file = "../output/graphs/elec_int2_pres21_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_fut.x

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.x)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.x) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int2_pres21_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.x))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))
  
ggsave(elec_int2_pres21_pad_3y4, file = "../output/graphs/elec_int2_pres21_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_fut.x

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.x)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.x) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_21) %>% filter(conv_padres_21==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int2_pres21_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.x))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))
  
ggsave(elec_int2_pres21_pad_3y4, file = "../output/graphs/elec_int2_pres21_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_fut.x

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.x)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.x) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int2_pres21_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.x))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))
  
ggsave(elec_int2_pres21_pad_3y4, file = "../output/graphs/elec_int2_pres21_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_fut.x

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.x)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.x) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int2_pres21_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.x))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))
  
ggsave(elec_int2_pres21_pad_3y4, file = "../output/graphs/elec_int2_pres21_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_fut.x

bbdd_general0 <- data_wide  %>% dplyr::select(voto_fut.x)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_fut.x) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_fut.x,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_fut.x) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_int2_pres21_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_fut.x))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "Aún no decido"))
  
ggsave(elec_int2_pres21_pad_3y4, file = "../output/graphs/elec_int2_pres21_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Elecciones constituyentes y municipales (mayo 2021)

Dependencia administrativa establecimiento

### variable voto_const 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_const)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_const) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_mun0 <- data_wide  %>% dplyr::select(voto_const,edm_admi) %>% filter(edm_admi==1)
bbdd_mun0 <- na.omit(bbdd_mun0)
bbdd_mun =
  bbdd_mun0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Municipal") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_sub0 <- data_wide  %>% dplyr::select(voto_const,edm_admi) %>% filter(edm_admi==2)
bbdd_sub0 <- na.omit(bbdd_sub0)
bbdd_sub =
  bbdd_sub0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Part. Subvencionado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_priv0 <- data_wide  %>% dplyr::select(voto_const,edm_admi) %>% filter(edm_admi==3)
bbdd_priv0 <- na.omit(bbdd_priv0)
bbdd_priv =
  bbdd_priv0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Part. Pagado") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_priv,bbdd_sub,bbdd_mun)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_const21_dep <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_const ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))

ggsave(elec_const21_dep, file = "../output/graphs/elec_const21_dep.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo de la madre

### variable voto_const 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_const)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_const) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_const,nse_madre) %>% filter(nse_madre==1 | nse_madre==2 | nse_madre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_const,nse_madre) %>% filter(nse_madre==4 | nse_madre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_const,nse_madre) %>% filter(nse_madre==6 | nse_madre==7 | nse_madre==8 | nse_madre==9 | nse_madre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_const21_edmad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_const   ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))

ggsave(elec_const21_edmad, file = "../output/graphs/elec_const21_edmad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Máximo nivel educativo del padre

### variable voto_const 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_const)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_const) %>%
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_bas0 <- data_wide  %>% dplyr::select(voto_const,nse_padre) %>% filter(nse_padre==1 | nse_padre==2 | nse_padre==3)
bbdd_ed_bas0 <- na.omit(bbdd_ed_bas0)
bbdd_ed_bas =
  bbdd_ed_bas0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>Ed. básica <br>o menos") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_med0 <- data_wide  %>% dplyr::select(voto_const,nse_padre) %>% filter(nse_padre==4 | nse_padre==5)
bbdd_ed_med0 <- na.omit(bbdd_ed_med0)
bbdd_ed_med =
  bbdd_ed_med0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>Ed. media") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_ed_ter0 <- data_wide  %>% dplyr::select(voto_const,nse_padre) %>% filter(nse_padre==6 | nse_padre==7 | nse_padre==8 | nse_padre==9 | nse_padre==10)
bbdd_ed_ter0 <- na.omit(bbdd_ed_ter0)
bbdd_ed_ter =
  bbdd_ed_ter0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>Ed. terciaria") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_ed_ter,bbdd_ed_med,bbdd_ed_bas)
bbdd_grafico<-na.omit(bbdd_grafico)
elec_const21_edpad <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_const   ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
    theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))

ggsave(elec_const21_edpad, file = "../output/graphs/elec_const21_edpad.jpg",device = "jpg",width = 23,height = 13,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en 3ro y 4to medio

### variable voto_const 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_const)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_const) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_const,conv_padr_poli) %>% filter(conv_padr_poli==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_const,conv_padr_poli) %>% filter(conv_padr_poli==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_const,conv_padr_poli) %>% filter(conv_padr_poli==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_const,conv_padr_poli) %>% filter(conv_padr_poli==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_const21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_const    ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_const21_conv_pad_3y4, file = "../output/graphs/elec_const21_conv_pad_3y4.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos en el estallido social

### variable voto_const 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_const)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_const) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_21) %>% filter(conv_padres_21==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_21) %>% filter(conv_padres_21==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_21) %>% filter(conv_padres_21==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_const21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_const    ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_const21_conv_pad_3y4, file = "../output/graphs/elec_const21_conv_pad_est_19.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el 2020

### variable voto_const 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_const)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_const) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_20) %>% filter(conv_padres_20==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_20) %>% filter(conv_padres_20==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_20) %>% filter(conv_padres_20==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_20) %>% filter(conv_padres_20==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_const21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_const    ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_const21_conv_pad_3y4, file = "../output/graphs/elec_const21_conv_pad_20.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el primer semestre del 2021

### variable voto_const 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_const)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_const) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_const,conv_padres) %>% filter(conv_padres==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_const,conv_padres) %>% filter(conv_padres==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_const,conv_padres) %>% filter(conv_padres==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_const,conv_padres) %>% filter(conv_padres==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_const21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_const    ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_const21_conv_pad_3y4, file = "../output/graphs/elec_const21_conv_pad_21a.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Frecuencia de conversación con los padres sobre temas sociales y/o políticos el segundo semestre del 2021

### variable voto_const 

bbdd_general0 <- data_wide  %>% dplyr::select(voto_const)
bbdd_general0 <- na.omit(bbdd_general0)
bbdd_general =
  bbdd_general0 %>% group_by(voto_const) %>%
  summarise(n=n(), tipe="<span style='color:#FFFFFF'>e</span>General") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_nunca0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_21b) %>% filter(conv_padres_21b==1)
bbdd_nunca0 <- na.omit(bbdd_nunca0)
bbdd_nunca =
  bbdd_nunca0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>d</span>4. Nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_casi_nunca0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_21b) %>% filter(conv_padres_21b==2)
bbdd_casi_nunca0 <- na.omit(bbdd_casi_nunca0)
bbdd_casi_nunca =
  bbdd_casi_nunca0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>c</span>3. Casi nunca") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_a_veces0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_21b) %>% filter(conv_padres_21b==3)
bbdd_a_veces0 <- na.omit(bbdd_a_veces0)
bbdd_a_veces =
  bbdd_a_veces0 %>% 
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>b</span>2. A veces") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_frecuent0 <- data_wide  %>% dplyr::select(voto_const,conv_padres_21b) %>% filter(conv_padres_21b==4)
bbdd_frecuent0 <- na.omit(bbdd_frecuent0)
bbdd_frecuent =
  bbdd_frecuent0 %>%
              group_by(voto_const) %>% #pregunta a graficar
             summarise(n=n(), tipe="<span style='color:#FFFFFF'>a</span>1. Frecuentemente") %>%
             mutate(prop=round(n*100/sum(n),1))

bbdd_grafico = rbind(bbdd_general,bbdd_nunca,bbdd_casi_nunca,bbdd_a_veces,bbdd_frecuent)
bbdd_grafico<-na.omit(bbdd_grafico)

elec_const21_conv_pad_3y4 <- bbdd_grafico %>% ggplot2::ggplot(aes(x=prop,y=tipe,fill=as.character(voto_const    ))) +  geom_bar(stat="identity",width = 0.5) +
  xlab("Porcentaje de respuestas según alternativa") +
  ylab("") +
  theme_minimal() +  # Fondo blanco con lineas
   geom_text(aes(x = prop, label = paste0(prop,"%")),
                  position = position_stack(vjust = .5),color="black", size=5) +
       theme(axis.text.x = element_markdown(colour = "grey20", size = 12, hjust = 0.7, vjust = 0.5, face = "bold"),
          axis.text.y = element_markdown(colour = "grey20", size = 14, face = "bold"), 
legend.position = "bottom", # legenda abajo
         plot.title = element_markdown(face="bold"), # titulo de grafico negrita
          #legend.text= element_markdown(size = 16), #
         legend.title = element_blank(),
         #text=element_text(size=16),
          legend.text = element_text(size=12, face = "bold")) +
  guides(fill = guide_legend(reverse=TRUE)) +
     scale_fill_brewer(palette="Purples", labels = c("No", "Sí", "No tenía edad"))
  
ggsave(elec_const21_conv_pad_3y4, file = "../output/graphs/elec_const21_conv_pad_21b.jpg",device = "jpg",width = 23,height = 13.5,dpi = "retina",units = "cm")

Correlaciones

Nivel educativo de la madre y PSU

data_cor_psu_edmad <- data_wide %>% select(nse_madre,edm_psu)

# edm_psu
corMat_psu_edmad  <- cor(data_cor_psu_edmad, use="na.or.complete", method = "spearman")
options(digits=3) # decimales
sjp.corr(corMat_psu_edmad, na.deletion = c("listwise"))

Nivel educativo del padre y PSU

data_cor_psu_edpad <- data_wide %>% select(nse_padre,edm_psu)

# edm_psu
corMat_psu_edpad  <- cor(data_cor_psu_edpad, use="na.or.complete", method = "spearman")
options(digits=3) # decimales
sjp.corr(corMat_psu_edpad, na.deletion = c("listwise"))

Nivel educativo propio y PSU

data_cor_psu_ed <- data_wide %>% select(cs_educ, cs_educ_w02, cs_educ_w03, edm_psu)

# edm_psu
corMat_psu_ed  <- cor(data_cor_psu_ed, use="na.or.complete", method = "spearman")
options(digits=3) # decimales
sjp.corr(corMat_psu_ed, na.deletion = c("listwise"))